本文整理汇总了C++中WorldServer::SendPacket方法的典型用法代码示例。如果您正苦于以下问题:C++ WorldServer::SendPacket方法的具体用法?C++ WorldServer::SendPacket怎么用?C++ WorldServer::SendPacket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldServer
的用法示例。
在下文中一共展示了WorldServer::SendPacket方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleClick
void Doors::HandleClick(Client* sender, uint8 trigger)
{
//door debugging info dump
Log.Out(Logs::Detail, Logs::Doors, "%s clicked door %s (dbid %d, eqid %d) at %s", sender->GetName(), door_name, db_id, door_id, to_string(m_Position).c_str());
Log.Out(Logs::Detail, Logs::Doors, " incline %d, opentype %d, lockpick %d, key %d, nokeyring %d, trigger %d type %d, param %d", incline, opentype, lockpick, keyitem, nokeyring, trigger_door, trigger_type, door_param);
Log.Out(Logs::Detail, Logs::Doors, " size %d, invert %d, dest: %s %s", size, invert_state, dest_zone, to_string(m_Destination).c_str());
EQApplicationPacket* outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
MoveDoor_Struct* md = (MoveDoor_Struct*)outapp->pBuffer;
md->doorid = door_id;
/////////////////////////////////////////////////////////////////
//used_pawn: Locked doors! Rogue friendly too =)
//TODO: add check for other lockpick items
//////////////////////////////////////////////////////////////////
//TODO: ADVENTURE DOOR
if(IsLDoNDoor())
{
if(sender)
{
if(RuleI(Adventure, ItemIDToEnablePorts) != 0)
{
if(!sender->KeyRingCheck(RuleI(Adventure, ItemIDToEnablePorts)))
{
if (sender->GetInv().HasItem(RuleI(Adventure, ItemIDToEnablePorts)) == INVALID_INDEX)
{
sender->Message_StringID(13, DUNGEON_SEALED);
safe_delete(outapp);
return;
}
else
{
sender->KeyRingAdd(RuleI(Adventure, ItemIDToEnablePorts));
}
}
}
if(!sender->GetPendingAdventureDoorClick())
{
sender->PendingAdventureDoorClick();
ServerPacket *pack = new ServerPacket(ServerOP_AdventureClickDoor, sizeof(ServerPlayerClickedAdventureDoor_Struct));
ServerPlayerClickedAdventureDoor_Struct *ads = (ServerPlayerClickedAdventureDoor_Struct*)pack->pBuffer;
strcpy(ads->player, sender->GetName());
ads->zone_id = zone->GetZoneID();
ads->id = GetDoorDBID();
worldserver.SendPacket(pack);
safe_delete(pack);
safe_delete(outapp);
}
return;
}
}
uint32 keyneeded = GetKeyItem();
uint8 keepoffkeyring = GetNoKeyring();
uint32 haskey = 0;
uint32 playerkey = 0;
const ItemInst *lockpicks = sender->GetInv().GetItem(MainCursor);
haskey = sender->GetInv().HasItem(keyneeded, 1);
if (haskey != INVALID_INDEX)
{
playerkey = keyneeded;
}
if(GetTriggerType() == 255)
{ // this object isnt triggered
if(trigger == 1)
{ // this door is only triggered by an object
if(!IsDoorOpen() || (opentype == 58))
{
md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
}
else
{
md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR;
}
}
else
{
safe_delete(outapp);
return;
}
}
// guild doors
if(((keyneeded == 0) && (GetLockpick() == 0) && (guild_id == 0)) ||
(IsDoorOpen() && (opentype == 58)) ||
((guild_id > 0) && (guild_id == sender->GuildID())))
{ //door not locked
if(!IsDoorOpen() || (opentype == 58))
{
md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
}
else
{
md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR;
}
}
//.........这里部分代码省略.........
示例2: ToggleEvent
void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool strict, bool reset_base) {
Log(Logs::Detail, Logs::Spawns, "Request to %s spawn event %d %sresetting trigger time", enabled?"enable":"disable", event_id, reset_base?"":"without ");
//first look for the event in our local event list
std::vector<SpawnEvent>::iterator cur,end;
cur = spawn_events.begin();
end = spawn_events.end();
for(; cur != end; ++cur) {
SpawnEvent &cevent = *cur;
if(cevent.id == event_id) {
//make sure were actually changing something
if(cevent.enabled != enabled || reset_base || cevent.strict != strict) {
cevent.enabled = enabled;
cevent.strict = strict;
if(reset_base) {
Log(Logs::Detail, Logs::Spawns, "Spawn event %d located in this zone. State set. Trigger time reset (period %d).", event_id, cevent.period);
//start with the time now
zone->zone_time.GetCurrentEQTimeOfDay(&cevent.next);
//advance the next time by our period
EQTime::AddMinutes(cevent.period, &cevent.next);
} else {
Log(Logs::Detail, Logs::Spawns, "Spawn event %d located in this zone. State changed.", event_id);
}
//save the event in the DB
UpdateDBEvent(cevent);
//sync up our nearest event
FindNearestEvent();
} else {
Log(Logs::Detail, Logs::Spawns, "Spawn event %d located in this zone but no change was needed.", event_id);
}
//even if we dont change anything, we still found it
return;
}
}
//if we get here, the condition must be in another zone.
//first figure out what zone it applies to.
//update the DB and send and send an update packet to
//the zone if its up
//we need to load the event from the DB and then update
//the values in the DB, because we do not know if the zone
//is up or not. The message to the zone will just tell it to
//update its in-memory event list
SpawnEvent e;
std::string zone_short_name;
if(!LoadDBEvent(event_id, e, zone_short_name)) {
Log(Logs::Detail, Logs::Spawns, "Unable to find spawn event %d in the database.", event_id);
//unable to find the event in the database...
return;
}
if(e.enabled == enabled && !reset_base) {
Log(Logs::Detail, Logs::Spawns, "Spawn event %d is not located in this zone but no change was needed.", event_id);
return; //no changes.
}
e.enabled = enabled;
if(reset_base) {
Log(Logs::Detail, Logs::Spawns, "Spawn event %d is in zone %s. State set. Trigger time reset (period %d). Notifying world.", event_id, zone_short_name.c_str(), e.period);
//start with the time now
zone->zone_time.GetCurrentEQTimeOfDay(&e.next);
//advance the next time by our period
EQTime::AddMinutes(e.period, &e.next);
} else {
Log(Logs::Detail, Logs::Spawns, "Spawn event %d is in zone %s. State changed. Notifying world.", event_id, zone_short_name.c_str(), e.period);
}
//save the event in the DB
UpdateDBEvent(e);
//now notify the zone
auto pack = new ServerPacket(ServerOP_SpawnEvent, sizeof(ServerSpawnEvent_Struct));
ServerSpawnEvent_Struct* sse = (ServerSpawnEvent_Struct*)pack->pBuffer;
sse->zoneID = database.GetZoneID(zone_short_name.c_str());
sse->event_id = event_id;
worldserver.SendPacket(pack);
safe_delete(pack);
}
示例3: SetCondition
void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance_id, uint16 condition_id, int16 new_value, bool world_update)
{
if(world_update) {
//this is an update coming from another zone, they
//have allready updated the DB, just need to update our
//memory, and check for condition changes
std::map<uint16, SpawnCondition>::iterator condi;
condi = spawn_conditions.find(condition_id);
if(condi == spawn_conditions.end()) {
Log(Logs::Detail, Logs::Spawns, "Condition update received from world for %d, but we do not have that conditon.", condition_id);
return; //unable to find the spawn condition
}
SpawnCondition &cond = condi->second;
if(cond.value == new_value) {
Log(Logs::Detail, Logs::Spawns, "Condition update received from world for %d with value %d, which is what we already have.", condition_id, new_value);
return;
}
int16 old_value = cond.value;
//set our local value
cond.value = new_value;
Log(Logs::Detail, Logs::Spawns, "Condition update received from world for %d with value %d", condition_id, new_value);
//now we have to test each spawn point to see if it changed.
zone->SpawnConditionChanged(cond, old_value);
} else if(!strcasecmp(zone_short, zone->GetShortName()) && instance_id == zone->GetInstanceID())
{
//this is a local spawn condition, we need to update the DB,
//our memory, then notify spawn points of the change.
std::map<uint16, SpawnCondition>::iterator condi;
condi = spawn_conditions.find(condition_id);
if(condi == spawn_conditions.end()) {
Log(Logs::Detail, Logs::Spawns, "Local Condition update requested for %d, but we do not have that conditon.", condition_id);
return; //unable to find the spawn condition
}
SpawnCondition &cond = condi->second;
if(cond.value == new_value) {
Log(Logs::Detail, Logs::Spawns, "Local Condition update requested for %d with value %d, which is what we already have.", condition_id, new_value);
return;
}
int16 old_value = cond.value;
//set our local value
cond.value = new_value;
//save it in the DB too
UpdateDBCondition(zone_short, instance_id, condition_id, new_value);
Log(Logs::Detail, Logs::Spawns, "Local Condition update requested for %d with value %d", condition_id, new_value);
//now we have to test each spawn point to see if it changed.
zone->SpawnConditionChanged(cond, old_value);
}
else
{
//this is a remote spawn condition, update the DB and send
//an update packet to the zone if its up
Log(Logs::Detail, Logs::Spawns, "Remote spawn condition %d set to %d. Updating DB and notifying world.", condition_id, new_value);
UpdateDBCondition(zone_short, instance_id, condition_id, new_value);
auto pack = new ServerPacket(ServerOP_SpawnCondition, sizeof(ServerSpawnCondition_Struct));
ServerSpawnCondition_Struct* ssc = (ServerSpawnCondition_Struct*)pack->pBuffer;
ssc->zoneID = database.GetZoneID(zone_short);
ssc->instanceID = instance_id;
ssc->condition_id = condition_id;
ssc->value = new_value;
worldserver.SendPacket(pack);
safe_delete(pack);
}
}
示例4: DelMember
bool Group::DelMember(Mob* oldmember,bool ignoresender)
{
if (oldmember == nullptr)
{
return false;
}
for (uint32 i = 0; i < MAX_GROUP_MEMBERS; i++)
{
if (members[i] == oldmember)
{
members[i] = nullptr;
membername[i][0] = '\0';
memset(membername[i],0,64);
MemberRoles[i] = 0;
Log.Out(Logs::Detail, Logs::Group, "DelMember: Removed Member: %s", oldmember->GetCleanName());
break;
}
}
if(GroupCount() < 2)
{
DisbandGroup();
return true;
}
// If the leader has quit and we have 2 or more players left in group, we want to first check the zone the old leader was in for a new leader.
// If a suitable replacement cannot be found, we need to go out of zone. If checkleader remains true after this method completes, another
// loop will be run in DelMemberOOZ.
bool checkleader = true;
if (strcmp(GetOldLeaderName(),oldmember->GetCleanName()) == 0 && GroupCount() >= 2)
{
for(uint32 nl = 0; nl < MAX_GROUP_MEMBERS; nl++)
{
if(members[nl])
{
if (members[nl]->IsClient())
{
ChangeLeader(members[nl]);
checkleader = false;
break;
}
}
}
}
ServerPacket* pack = new ServerPacket(ServerOP_GroupLeave, sizeof(ServerGroupLeave_Struct));
ServerGroupLeave_Struct* gl = (ServerGroupLeave_Struct*)pack->pBuffer;
gl->gid = GetID();
gl->zoneid = zone->GetZoneID();
gl->instance_id = zone->GetInstanceID();
strcpy(gl->member_name, oldmember->GetName());
gl->checkleader = checkleader;
worldserver.SendPacket(pack);
safe_delete(pack);
EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupJoin_Struct));
GroupJoin_Struct* gu = (GroupJoin_Struct*)outapp->pBuffer;
gu->action = groupActLeave;
strcpy(gu->membername, oldmember->GetCleanName());
strcpy(gu->yourname, oldmember->GetCleanName());
for (uint32 i = 0; i < MAX_GROUP_MEMBERS; i++) {
if (members[i] == nullptr) {
//if (DEBUG>=5) Log.Out(Logs::Detail, Logs::Group, "Group::DelMember() null member at slot %i", i);
continue;
}
if (members[i] != oldmember) {
strcpy(gu->yourname, members[i]->GetCleanName());
if(members[i]->IsClient())
members[i]->CastToClient()->QueuePacket(outapp);
}
}
if (!ignoresender)
{
strcpy(gu->yourname,oldmember->GetCleanName());
strcpy(gu->membername,oldmember->GetCleanName());
gu->action = groupActLeave;
if(oldmember->IsClient())
oldmember->CastToClient()->QueuePacket(outapp);
}
if(oldmember->IsClient())
{
database.SetGroupID(oldmember->GetCleanName(), 0, oldmember->CastToClient()->CharacterID());
}
oldmember->SetGrouped(false);
disbandcheck = true;
safe_delete(outapp);
return true;
}
示例5: GuildCommand
//.........这里部分代码省略.........
{
Message(BLACK, "You arent in a guild!");
}
else if (!guilds[guildeqid].rank[guildrank].motd)
{
Message(BLACK, "You dont have permission to change the motd.");
}
else if (!worldserver.Connected())
{
Message(BLACK, "Error: World server dirconnected");
}
else
{
char tmp[255];
if (strcasecmp(sep->argplus[2], "none") == 0)
{
strcpy(tmp, "");
}
else
{
snprintf(tmp, sizeof(tmp), "%s - %s", this->GetName(), sep->argplus[2]);
}
if (Database::Instance()->SetGuildMOTD(guilddbid, tmp))
{
// Dark-Prince - 10/05/2008 - Code Consolidation
/*
ServerPacket* pack = new ServerPacket;
pack->opcode = ServerOP_RefreshGuild;
pack->size = 5;
pack->pBuffer = new uchar[pack->size];
memcpy(pack->pBuffer, &guildeqid, 4);
worldserver.SendPacket(pack);
safe_delete(pack);//delete pack;
*/
}
else
{
this->Message(BLACK, "Motd update failed.");
}
}
}
else if (strcasecmp(sep->arg[1], "edit") == 0)
{
if (guilddbid == 0)
{
Message(BLACK, "You arent in a guild!");
}
else if (!sep->IsNumber(2))
{
Message(BLACK, "Error: invalid rank #.");
}
else if (atoi(sep->arg[2]) < 0 || atoi(sep->arg[2]) > GUILD_MAX_RANK)
{
Message(BLACK, "Error: invalid rank #.");
}
else if (!guildrank == 0)
{
Message(BLACK, "You must be rank %s to use edit.", guilds[guildeqid].rank[0].rankname);
}
else if (!worldserver.Connected())
{
Message(BLACK, "Error: World server dirconnected");
}
else
示例6: DoZoneSuccess
void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instance_id, float dest_x, float dest_y, float dest_z, float dest_h, int8 ignore_r) {
//this is called once the client is fully allowed to zone here
//it takes care of all the activities which occur when a client zones out
SendLogoutPackets();
//dont clear aggro until the zone is successful
entity_list.RemoveFromHateLists(this);
if(this->GetPet())
entity_list.RemoveFromHateLists(this->GetPet());
LogFile->write(EQEMuLog::Status, "Zoning '%s' to: %s (%i) - (%i) x=%f, y=%f, z=%f",
m_pp.name, database.GetZoneName(zone_id), zone_id, instance_id,
dest_x, dest_y, dest_z);
//set the player's coordinates in the new zone so they have them
//when they zone into it
x_pos = dest_x; //these coordinates will now be saved when ~client is called
y_pos = dest_y;
z_pos = dest_z;
heading = dest_h; // Cripp: fix for zone heading
m_pp.heading = dest_h;
m_pp.zone_id = zone_id;
m_pp.zoneInstance = instance_id;
//Force a save so its waiting for them when they zone
Save(2);
if (zone_id == zone->GetZoneID() && instance_id == zone->GetInstanceID()) {
// No need to ask worldserver if we're zoning to ourselves (most
// likely to a bind point), also fixes a bug since the default response was failure
EQApplicationPacket* outapp = new EQApplicationPacket(OP_ZoneChange,sizeof(ZoneChange_Struct));
ZoneChange_Struct* zc2 = (ZoneChange_Struct*) outapp->pBuffer;
strcpy(zc2->char_name, GetName());
zc2->zoneID = zone_id;
zc2->instanceID = instance_id;
zc2->success = 1;
outapp->priority = 6;
FastQueuePacket(&outapp);
zone->StartShutdownTimer(AUTHENTICATION_TIMEOUT * 1000);
} else {
// vesuvias - zoneing to another zone so we need to the let the world server
//handle things with the client for a while
ServerPacket* pack = new ServerPacket(ServerOP_ZoneToZoneRequest, sizeof(ZoneToZone_Struct));
ZoneToZone_Struct* ztz = (ZoneToZone_Struct*) pack->pBuffer;
ztz->response = 0;
ztz->current_zone_id = zone->GetZoneID();
ztz->current_instance_id = zone->GetInstanceID();
ztz->requested_zone_id = zone_id;
ztz->requested_instance_id = instance_id;
ztz->admin = admin;
ztz->ignorerestrictions = ignore_r;
strcpy(ztz->name, GetName());
ztz->guild_id = GuildID();
worldserver.SendPacket(pack);
safe_delete(pack);
}
//reset to unsolicited.
zone_mode = ZoneUnsolicited;
zonesummon_x = 0;
zonesummon_y = 0;
zonesummon_z = 0;
zonesummon_id = 0;
zonesummon_ignorerestrictions = 0;
}
示例7: Process
void WorldServer::Process()
{
if(this == 0)
{
return;
}
if(!Connected())
{
return;
}
SOCKADDR_IN to;
memset((char *) &to, 0, sizeof(to));
to.sin_family = AF_INET;
to.sin_port = port;
to.sin_addr.s_addr = ip;
/************ Get all packets from packet manager out queue and process them ************/
ServerPacket *pack = 0;
while(pack = ServerRecvQueuePop())
{
switch(pack->opcode)
{
case 0:
{
break;
}
case ServerOP_KeepAlive:
{
// ignore this
break;
}
case ServerOP_ChannelMessage:
{
if (!ZoneLoaded) break;
ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*) pack->pBuffer;
if (scm->deliverto[0] == 0)
{
entity_list.ChannelMessageFromWorld(scm->from, scm->to, scm->chan_num, scm->guilddbid, scm->language, scm->message);
}
else
{
Client* client;
client = entity_list.GetClientByName(scm->deliverto);
if (client != 0)
{
if (client->Connected())
{
client->ChannelMessageSend(scm->from, scm->to, scm->chan_num, scm->language, scm->message);
if (!scm->noreply)
{
// if it's a tell, echo back so it shows up
scm->noreply = true;
scm->chan_num = 14;
memset(scm->deliverto, 0, sizeof(scm->deliverto));
strcpy(scm->deliverto, scm->from);
SendPacket(pack);
}
}
}
}
break;
}
case ServerOP_EmoteMessage:
{
if (!ZoneLoaded)
{
break;
}
ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*) pack->pBuffer;
if (sem->to[0] != 0)
{
if (strcasecmp(sem->to, zone->GetShortName()) == 0)
{
entity_list.Message(sem->guilddbid, (MessageFormat)sem->type, sem->message);
}
else
{
Client* client = entity_list.GetClientByName(sem->to);
if (client != 0)
{
client->Message((MessageFormat)sem->type, sem->message);
}
}
}
else
{
entity_list.Message(sem->guilddbid, (MessageFormat)sem->type, sem->message);
}
break;
}
/* case ServerOP_GroupRefresh: //Kibanu - 4/22/2009
{
cout << "WorldServer_Process: In Group Refresh" << endl;
if (!ZoneLoaded)
{
break;
}
//.........这里部分代码省略.........