bool WorldSession::Update(uint32 diff) { WorldPacket *packet; OpcodeHandler *table = _GetOpcodeHandlerTable(); uint32 i; while (!_recvQueue.empty()) { packet = _recvQueue.next(); if(packet==NULL) continue; for (i = 0; table[i].handler != NULL; i++) { if (table[i].opcode == packet->GetOpcode()) { if (table[i].status == STATUS_AUTHED || (table[i].status == STATUS_LOGGEDIN && _player)) { (this->*table[i].handler)(*packet); } else { sLog.outError( "SESSION: received unexpected opcode %s (0x%.4X)", LookupName(packet->GetOpcode(), g_worldOpcodeNames), packet->GetOpcode()); } break; } } if (table[i].handler == NULL) sLog.outError( "SESSION: received unhandled opcode %s (0x%.4X)", LookupName(packet->GetOpcode(), g_worldOpcodeNames), packet->GetOpcode()); delete packet; } time_t currTime = time(NULL); if (!_socket || ShouldLogOut(currTime)) LogoutPlayer(true); if (!_socket) return false; return true; }
AJ_Status AJ_GetGroupKey(const char* name, uint8_t* key) { // AJ_InfoPrintf(("AJ_GetGroupKey(name=\"%s\", key=0x%p)\n", name, key)); if (name) { NameToGUID* mapping = LookupName(name); if (!mapping) { // AJ_WarnPrintf(("AJ_GetGroupKey(): AJ_ERR_NO_MATCH\n")); return AJ_ERR_NO_MATCH; } memcpy(key, mapping->groupKey, 16); } else { // Check if the group key needs to be initialized memset(key, 0, 16); if (memcmp(localGroupKey, key, 16) == 0) { AJ_RandBytes(localGroupKey, 16); } memcpy(key, localGroupKey, 16); } return AJ_OK; }
/* ************************************************************************************** * ReadNames: * Read all the position names in the position definiton file and store * them in the POSITIONS table. Also, allocate and initialize the HP Line * share logical vectors for every name read. ************************************************************************************** */ void ReadNames() { int p = 0; char *ptr; char *nameptr; infof("Reading position definition names..."); while (NextLine()) { if (strncmp(IOBuff,"DEFINE POSITION ",16)) continue; ptr = IOBuff + 16; nameptr = NextToken(&ptr,DYNAMIC_STRING); if (nameptr == NULL) { errorfp("Missing name at line %d",CurrentLine); continue; } if (!CopyValidName(nameptr,Positions[p].name.name)) errorfp("Invalid name %s at line %d",nameptr,CurrentLine); if (LookupName(Positions[p].name.name) != p) errorfp("Multiply defined name %s at line %d", Positions[p].name.name,CurrentLine); p++; free(nameptr); } if (p != TotalPositions) { errorfp("Expected %d names, found %d",TotalPositions,p); TotalPositions = p; } }
const AJ_GUID* AJ_GUID_Find(const char* name) { NameToGUID* mapping = LookupName(name); // AJ_InfoPrintf(("AJ_GUID_Find(name=\"%s\")\n", name)); return mapping ? &mapping->guid : NULL; }
void AJ_GUID_DeleteNameMapping(const char* uniqueName) { NameToGUID* mapping = LookupName(uniqueName); if (mapping) { memset(mapping, 0, sizeof(NameToGUID)); } }
AJ_Status AJ_GUID_AddNameMapping(const AJ_GUID* guid, const char* uniqueName, const char* serviceName) { size_t len = strlen(uniqueName); NameToGUID* mapping = LookupName(uniqueName); if (!mapping) { mapping = LookupName(""); } if (mapping && (len <= MAX_NAME_SIZE)) { memcpy(&mapping->guid, guid, sizeof(AJ_GUID)); memcpy(&mapping->uniqueName, uniqueName, len + 1); mapping->serviceName = serviceName; return AJ_OK; } else { return AJ_ERR_RESOURCES; } }
AJ_Status AJ_SetGroupKey(const char* uniqueName, const uint8_t* key) { NameToGUID* mapping = LookupName(uniqueName); if (mapping) { memcpy(mapping->groupKey, key, 16); return AJ_OK; } else { return AJ_ERR_NO_MATCH; } }
const Waypoint & Waypoints::CheckExistsOrAppend(const Waypoint &waypoint) { const Waypoint* found = LookupName(waypoint.name); if (found && found->IsCloseTo(waypoint.location, fixed(100))) { return *found; } return Append(waypoint); }
AJ_Status AJ_SetSessionKey(const char* uniqueName, const uint8_t* key, uint8_t role) { NameToGUID* mapping = LookupName(uniqueName); if (mapping) { mapping->keyRole = role; memcpy(mapping->sessionKey, key, 16); return AJ_OK; } else { return AJ_ERR_NO_MATCH; } }
AJ_Status AJ_GetSessionKey(const char* name, uint8_t* key, uint8_t* role) { NameToGUID* mapping = LookupName(name); if (mapping) { *role = mapping->keyRole; memcpy(key, mapping->sessionKey, 16); return AJ_OK; } else { return AJ_ERR_NO_MATCH; } }
BOOLEAN parseBuiltInTypelistFunc(LEXEME **lex, SYMBOL *funcsp, SYMBOL *sym, TYPE **tp, EXPRESSION **exp) { HASHREC **hr = LookupName(sym->name, intrinsicHash); if (hr) { struct _ihash *p = (struct _ihash *)(*hr)->p; return p->func(lex, funcsp, sym, tp, exp); } return FALSE; }
SYMBOL *search(char *name, HASHTABLE *table) { while (table) { HASHREC **p = LookupName(name, table); if (p) return (SYMBOL *)(*p)->p; table = table->next; } return NULL; }
AJ_Status AJ_GUID_AddNameMapping(AJ_BusAttachment* bus, const AJ_GUID* guid, const char* uniqueName, const char* serviceName) { AJ_Status status; size_t len = strlen(uniqueName); NameToGUID* mapping; int isNew; uint32_t serialNum; // AJ_InfoPrintf(("AJ_GUID_AddNameMapping(guid=0x%p, uniqueName=\"%s\", serviceName=\"%s\")\n", guid, uniqueName, serviceName)); mapping = LookupName(uniqueName); isNew = !mapping; if (isNew) { mapping = LookupName(""); } if (mapping && (len <= AJ_MAX_NAME_SIZE)) { if (isNew && (AJ_GetRoutingProtoVersion() >= 11)) { status = SetNameOwnerChangedRule(bus, uniqueName, AJ_BUS_SIGNAL_ALLOW, &serialNum); if (status != AJ_OK) { AJ_ErrPrintf(("AJ_GUID_AddNameMapping(guid=0x%p, uniqueName=\"%s\", serviceName=\"%s\"): Add match rule error\n", guid, uniqueName, serviceName)); return status; } mapping->replySerial = serialNum; } memcpy(&mapping->guid, guid, sizeof(AJ_GUID)); memcpy(&mapping->uniqueName, uniqueName, len + 1); mapping->serviceName = serviceName; mapping->incoming.serial = 0; mapping->incoming.offset = 0; return AJ_OK; } else { AJ_ErrPrintf(("AJ_GUID_AddNameMapping(): AJ_ERR_RESOURCES\n")); return AJ_ERR_RESOURCES; } }
static int ccSelectIdFromNameTable( sqlite3_stmt **shndl, char *name, char *tabname, sqlite3_int64 *id, HASHTABLE *table) { static char *query = "SELECT id FROM %s WHERE name = ?"; int rc = SQLITE_OK; HASHREC **p = LookupName(name, table); SYMID *v; if (p) { *id = ((SYMID *)((*p)->p))->id; return rc; } /* if (!*shndl) { char qbuf[256]; sprintf(qbuf, query, tabname); rc = sqlite3_prepare_v2(dbPointer, qbuf, strlen(qbuf)+1, shndl, NULL); } if (rc == SQLITE_OK) { int done = FALSE; rc = SQLITE_DONE; sqlite3_reset(*shndl); sqlite3_bind_text(*shndl, 1, name, strlen(name), SQLITE_STATIC); while (!done) { switch(rc = sqlite3_step(*shndl)) { case SQLITE_BUSY: done = TRUE; break; case SQLITE_DONE: done = TRUE; break; case SQLITE_ROW: v = (SYMID *)Alloc(sizeof(SYMID)); v->name = name; *id = sqlite3_column_int64(*shndl, 0); v->id = *id; AddName((SYMBOL *)v, table); rc = SQLITE_OK; done = TRUE; break; default: done = TRUE; break; } } } return rc; */ return SQLITE_ERROR; }
int ccWriteFileName( char *name, sqlite_int64 *id) { char buf[260], *p = buf; HASHREC **q; while (*name) *p++ = tolower(*name++); *p = 0; q = LookupName(buf, listf); if (q) { *id = ((SYMID *)((*q)->p))->id; return TRUE; } name = litlate(buf); return ccWriteNameInTable(&whndlf, &shndlf, name, "FileNames", id, listf) == SQLITE_OK; }
AJ_Status AJ_GetRemoteUniqueName(const char* name, const char** unique) { NameToGUID* mapping; // AJ_InfoPrintf(("AJ_GetRemoteUniqueName(name=\"%s\", unique=%p)\n", name, unique)); mapping = LookupName(name); if (mapping) { *unique = mapping->uniqueName; return AJ_OK; } else { return AJ_ERR_NO_MATCH; } }
AJ_Status AJ_SetGroupKey(const char* uniqueName, const uint8_t* key) { NameToGUID* mapping; // AJ_InfoPrintf(("AJ_SetGroupKey(uniqueName=\"%s\", key=0x%p)\n", uniqueName, key)); mapping = LookupName(uniqueName); if (mapping) { memcpy(mapping->groupKey, key, 16); return AJ_OK; } else { // AJ_WarnPrintf(("AJ_SetGroupKey(): AJ_ERR_NO_MATCH\n")); return AJ_ERR_NO_MATCH; } }
void ClusterInterface::HandleWoWPacket(WorldPacket & pck) { uint32 size, sid; uint16 opcode; pck >> sid >> opcode >> size; if(!_sessions[sid]) { Log.Error("HandleWoWPacket", "Invalid session: %u", sid); return; } DEBUG_LOG("HandleWoWPacket", "Forwarding %s to client", LookupName(opcode, g_worldOpcodeNames)); WorldPacket * npck = new WorldPacket(opcode, size); npck->resize(size); memcpy((void*)npck->contents(), pck.contents()+10, size); _sessions[sid]->QueuePacket(npck); }
/// Handle the update order for the socket void WorldSocket::Update(time_t diff) { WorldPacket *packet; ServerPktHeader hdr; ///- While we have packets to send while(!_sendQueue.empty()) { packet = _sendQueue.next(); hdr.size = ntohs((uint16)packet->size() + 2); hdr.cmd = packet->GetOpcode(); if( sWorldLog.LogWorld() ) { sWorldLog.Log("SERVER:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n", (uint32)GetSocket(), packet->size(), LookupName(packet->GetOpcode(), g_worldOpcodeNames), packet->GetOpcode()); uint32 p = 0; while (p < packet->size()) { for (uint32 j = 0; j < 16 && p < packet->size(); j++) sWorldLog.Log("%.2X ", (*packet)[p++]); sWorldLog.Log("\n"); } sWorldLog.Log("\n\n"); } ///- Encrypt (if needed) the header _crypt.EncryptSend((uint8*)&hdr, 4); ///- Send the header and body to the client TcpSocket::SendBuf((char*)&hdr, 4); if(packet->size()) TcpSocket::SendBuf((char*)packet->contents(), packet->size()); delete packet; } }
void Waypoints::AddTakeoffPoint(const GeoPoint& location, const fixed terrain_alt) { // remove old one first const Waypoint *old_takeoff_point = LookupName(_T("(takeoff)")); if (old_takeoff_point != NULL) Erase(*old_takeoff_point); const Waypoint *nearest_landable = GetNearestLandable(location, fixed(5000)); if (!nearest_landable) { // now add new and update database Waypoint new_waypoint = GenerateTakeoffPoint(location, terrain_alt); Append(new_waypoint); } Optimise(); }
AJ_Status AJ_SetSessionKey(const char* uniqueName, const uint8_t* key, uint8_t role, uint32_t authVersion) { NameToGUID* mapping; // AJ_InfoPrintf(("AJ_SetGroupKey(uniqueName=\"%s\", key=0x%p)\n", uniqueName, key)); mapping = LookupName(uniqueName); if (mapping) { mapping->keyRole = role; mapping->authVersion = authVersion; memcpy(mapping->sessionKey, key, 16); return AJ_OK; } else { // AJ_WarnPrintf(("AJ_SetSessionKey(): AJ_ERR_NO_MATCH\n")); return AJ_ERR_NO_MATCH; } }
AJ_Status AJ_GetGroupKey(const char* name, uint8_t* key) { if (name) { NameToGUID* mapping = LookupName(name); if (!mapping) { return AJ_ERR_NO_MATCH; } memcpy(key, mapping->groupKey, 16); } else { /* * Check if the group key needs to be initialized */ memset(key, 0, 16); if (memcmp(localGroupKey, key, 16) == 0) { AJ_RandBytes(localGroupKey, 16); } memcpy(key, localGroupKey, 16); } return AJ_OK; }
void AJ_GUID_DeleteNameMapping(AJ_BusAttachment* bus, const char* uniqueName) { AJ_Status status; NameToGUID* mapping; // AJ_InfoPrintf(("AJ_GUID_DeleteNameMapping(uniqueName=\"%s\")\n", uniqueName)); mapping = LookupName(uniqueName); if (mapping) { if (AJ_GetRoutingProtoVersion() >= 11) { status = SetNameOwnerChangedRule(bus, uniqueName, AJ_BUS_SIGNAL_DENY, NULL); if (status != AJ_OK) { // AJ_WarnPrintf(("AJ_GUID_DeleteNameMapping(uniqueName=\"%s\"): Remove match rule error\n", uniqueName)); } } memset(mapping, 0, sizeof(NameToGUID)); } }
AJ_Status AJ_GetSessionKey(const char* name, uint8_t* key, uint8_t* role, uint32_t* authVersion) { NameToGUID* mapping; // AJ_InfoPrintf(("AJ_GetSessionKey(name=\"%s\", key=0x%p, role=0x%p)\n", name, key, role)); mapping = LookupName(name); if (mapping) { *role = mapping->keyRole; *authVersion = mapping->authVersion; memcpy(key, mapping->sessionKey, 16); return AJ_OK; } else { // AJ_WarnPrintf(("AJ_GetSessionKey(): AJ_ERR_NO_MATCH\n")); return AJ_ERR_NO_MATCH; } }
AJ_Status AJ_GetSerialNumbers(const char* name, AJ_SerialNum** incoming) { NameToGUID* mapping; // AJ_InfoPrintf(("AJ_GetSerialNumbers(name=\"%s\", incoming=%p)\n", name, incoming)); mapping = LookupName(name); if (mapping) { if (incoming) { *incoming = &mapping->incoming; } return AJ_OK; } else { // AJ_WarnPrintf(("AJ_GetSerialNumbers(): AJ_ERR_NO_MATCH\n")); return AJ_ERR_NO_MATCH; } }
// Wraps LookupName() to provide a Python method interface. // Arguments: // - address of the device to look up. Note that the address // is expected without colons!! e.g. "000D9319C868" // - True/False - if True, performs a remote name request even if the device // name is known in the cache from a previous request. // // Returns the name (a Python unicode string). static PyObject* LightBlue_LookupName(PyObject* self, PyObject* args) { const char *addr; bool ignoreCache; if (!PyArg_ParseTuple(args, "sb", &addr, &ignoreCache)) return NULL; THostName deviceName; TBTDevAddr wantedAddr; TBuf16<128> buf; buf.Copy(_L8(addr)); wantedAddr.SetReadable(buf); TInt err = LookupName(wantedAddr, &deviceName, ignoreCache); if (err) return SPyErr_SetFromSymbianOSErr(err); return Py_BuildValue("u#", deviceName.Ptr(), deviceName.Length()); }
void ClusterInterface::ForwardWoWPacket(uint16 opcode, uint32 size, const void * data, uint32 sessionid) { DEBUG_LOG("ForwardWoWPacket", "Forwarding %s to server", LookupName(opcode, g_worldOpcodeNames)); bool rv; uint32 size2 = 10 + size; uint16 opcode2 = ICMSG_WOW_PACKET; if(!_clientSocket || !m_connected) return; // Shouldn't happen _clientSocket->BurstBegin(); _clientSocket->BurstSend((const uint8*)&opcode2, 2); _clientSocket->BurstSend((const uint8*)&size2, 4); _clientSocket->BurstSend((const uint8*)&sessionid, 4); _clientSocket->BurstSend((const uint8*)&opcode, 2); rv=_clientSocket->BurstSend((const uint8*)&size, 4); if(size&&rv) rv=_clientSocket->BurstSend((const uint8*)data, size); if(rv) _clientSocket->BurstPush(); _clientSocket->BurstEnd(); }
static int ccWriteMap( sqlite_int64 smpl_id, sqlite_int64 cplx_id, sqlite_int64 main_id) { char id[256]; static char *query = "INSERT INTO CPPNameMapping (simpleId, complexId, mainid) VALUES (?, ?, ?)"; int rc = SQLITE_OK; static sqlite3_stmt *handle, *handle1; if (!handle) rc = sqlite3_prepare_v2(dbPointer, query, strlen(query)+1, &handle, NULL); sprintf(id, "%d,%d", (int)smpl_id, (int)cplx_id); if (!LookupName(id, map)) { int done = FALSE; SYMID *v = (SYMID *)Alloc(sizeof(SYMID)); v->name = litlate(id); AddName((SYMBOL *)v, map); rc = SQLITE_DONE; sqlite3_reset(handle); sqlite3_bind_int64(handle, 1, smpl_id); sqlite3_bind_int64(handle, 2, cplx_id); sqlite3_bind_int64(handle, 3, main_id); while (!done) { switch(rc = sqlite3_step(handle)) { case SQLITE_BUSY: done = TRUE; break; case SQLITE_DONE: done = TRUE; rc = SQLITE_OK; break; default: done = TRUE; break; } } } return rc; }
NTSTATUS EXTERNAL HbtnCreateClose( IN PDEVICE_OBJECT DevObject, IN PIRP Irp ) { NTSTATUS status = STATUS_SUCCESS; PIO_STACK_LOCATION irpsp = NULL; PAGED_CODE (); UNREFERENCED_PARAMETER(DevObject); irpsp = IoGetCurrentIrpStackLocation(Irp); TEnter(Func,("(DevObject=%p,Irp=%p,IrpStack=%p,Major=%s)\n", DevObject, Irp, irpsp, LookupName(irpsp->MajorFunction, MajorIrpNames))); switch(irpsp->MajorFunction) { case IRP_MJ_CREATE: case IRP_MJ_CLOSE: Irp->IoStatus.Information = 0; break; default: status = STATUS_INVALID_PARAMETER; break; } Irp->IoStatus.Status = status; IoCompleteRequest(Irp, IO_NO_INCREMENT); TExit(Func,("=%x\n", status)); return status; } //HbtnCreateClose
void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) { bool moved = true; if(!_player->IsInWorld() || _player->m_uint32Values[UNIT_FIELD_CHARMEDBY] || _player->GetPlayerStatus() == TRANSFER_PENDING || _player->GetTaxiState()) return; // spell cancel on movement, for now only fishing is added Object * t_go = _player->m_SummonedObject; if (t_go) { if (t_go->GetEntry() == GO_FISHING_BOBBER) ((GameObject*)t_go)->EndFishing(GetPlayer(),true); } /************************************************************************/ /* Clear standing state to stand. */ /************************************************************************/ if( recv_data.GetOpcode() == MSG_MOVE_START_FORWARD ) _player->SetStandState( STANDSTATE_STAND ); /************************************************************************/ /* Make sure the packet is the correct size range. */ /************************************************************************/ if(recv_data.size() > 80) { Disconnect(); return; } /************************************************************************/ /* Read Movement Data Packet */ /************************************************************************/ movement_info.init(recv_data); /************************************************************************/ /* Update player movement state */ /************************************************************************/ switch( recv_data.GetOpcode() ) { case MSG_MOVE_START_FORWARD: case MSG_MOVE_START_BACKWARD: _player->moving = true; break; case MSG_MOVE_START_STRAFE_LEFT: case MSG_MOVE_START_STRAFE_RIGHT: _player->strafing = true; break; case MSG_MOVE_JUMP: _player->jumping = true; break; case MSG_MOVE_STOP: _player->moving = false; break; case MSG_MOVE_STOP_STRAFE: _player->strafing = false; break; case MSG_MOVE_FALL_LAND: _player->jumping = false; break; default: moved = false; break; } if( moved ) { if( !_player->moving && !_player->strafing && !_player->jumping ) _player->m_isMoving = false; else _player->m_isMoving = true; } /************************************************************************/ /* Anti-Fly Hack Checks */ /************************************************************************/ if( sWorld.antihack_flight && ( recv_data.GetOpcode() == CMSG_MOVE_FLY_START_AND_END || recv_data.GetOpcode() == CMSG_FLY_PITCH_DOWN_AFTER_UP ) && !( movement_info.flags & MOVEFLAG_SWIMMING || movement_info.flags & MOVEFLAG_FALLING || movement_info.flags & MOVEFLAG_FALLING_FAR || movement_info.flags & MOVEFLAG_FREE_FALLING ) && _player->flying_aura == 0 ) { if( sWorld.no_antihack_on_gm && _player->GetSession()->HasGMPermissions() ) { // Do nothing. } else { _player->BroadcastMessage( "Flyhack detected. In case the server is wrong then make a report how to reproduce this case. You will be logged out in 5 seconds." ); sEventMgr.AddEvent( _player, &Player::_Kick, EVENT_PLAYER_KICK, 5000, 1, 0 ); } } //update the detector if( sWorld.antihack_speed && !_player->GetTaxiState() && _player->m_TransporterGUID == 0 && !_player->GetSession()->GetPermissionCount()) { // simplified: just take the fastest speed. less chance of fuckups too float speed = ( _player->flying_aura ) ? _player->m_flySpeed : ( _player->m_swimSpeed >_player-> m_runSpeed ) ? _player->m_swimSpeed : _player->m_runSpeed; _player->SDetector->AddSample( movement_info.x, movement_info.y, getMSTime(), speed ); if( _player->SDetector->IsCheatDetected() ) _player->SDetector->ReportCheater( _player ); } /************************************************************************/ /* Remove Emote State */ /************************************************************************/ if(_player->m_uint32Values[UNIT_NPC_EMOTESTATE]) _player->SetUInt32Value(UNIT_NPC_EMOTESTATE,0); /************************************************************************/ /* Make sure the co-ordinates are valid. */ /************************************************************************/ if( !((movement_info.y >= _minY) && (movement_info.y <= _maxY)) || !((movement_info.x >= _minX) && (movement_info.x <= _maxX)) ) { Disconnect(); return; } /************************************************************************/ /* Dump movement flags - Wheee! */ /************************************************************************/ #if 0 printf("=========================================================\n"); printf("Full movement flags: 0x%.8X\n", movement_info.flags); uint32 z, b; for(z = 1, b = 1; b < 32;) { if(movement_info.flags & z) printf(" Bit %u (0x%.8X or %u) is set!\n", b, z, z); z <<= 1; b+=1; } printf("=========================================================\n"); #endif /************************************************************************/ /* Orientation dumping */ /************************************************************************/ #if 0 printf("Packet: 0x%03X (%s)\n", recv_data.GetOpcode(), LookupName( recv_data.GetOpcode(), g_worldOpcodeNames ) ); printf("Orientation: %.10f\n", movement_info.orientation); #endif /************************************************************************/ /* Calculate the timestamp of the packet we have to send out */ /************************************************************************/ size_t pos = (size_t)m_MoverWoWGuid.GetNewGuidLen() + 1; uint32 mstime = mTimeStamp(); int32 move_time; if(m_clientTimeDelay == 0) m_clientTimeDelay = mstime - movement_info.time; /************************************************************************/ /* Copy into the output buffer. */ /************************************************************************/ if(_player->m_inRangePlayers.size()) { move_time = (movement_info.time - (mstime - m_clientTimeDelay)) + MOVEMENT_PACKET_TIME_DELAY + mstime; memcpy(&movement_packet[pos], recv_data.contents(), recv_data.size()); movement_packet[pos+5]=0; /************************************************************************/ /* Distribute to all inrange players. */ /************************************************************************/ for(set<Player*>::iterator itr = _player->m_inRangePlayers.begin(); itr != _player->m_inRangePlayers.end(); ++itr) { #ifdef USING_BIG_ENDIAN *(uint32*)&movement_packet[pos+5] = swap32(move_time + (*itr)->GetSession()->m_moveDelayTime); #else *(uint32*)&movement_packet[pos+5] = uint32(move_time + (*itr)->GetSession()->m_moveDelayTime); #endif #if defined(ENABLE_COMPRESSED_MOVEMENT) && defined(ENABLE_COMPRESSED_MOVEMENT_FOR_PLAYERS) if( _player->GetPositionNC().Distance2DSq((*itr)->GetPosition()) >= World::m_movementCompressThreshold ) (*itr)->AppendMovementData( recv_data.GetOpcode(), uint16(recv_data.size() + pos), movement_packet ); else (*itr)->GetSession()->OutPacket(recv_data.GetOpcode(), uint16(recv_data.size() + pos), movement_packet); #else (*itr)->GetSession()->OutPacket(recv_data.GetOpcode(), uint16(recv_data.size() + pos), movement_packet); #endif } } /************************************************************************/ /* Falling damage checks */ /************************************************************************/ if( _player->blinked ) { _player->blinked = false; _player->m_fallDisabledUntil = UNIXTIME + 5; _player->SpeedCheatDelay( 2000 ); //some say they managed to trigger system with knockback. Maybe they moved in air ? } else { if( recv_data.GetOpcode() == MSG_MOVE_FALL_LAND ) { // player has finished falling //if _player->z_axisposition contains no data then set to current position if( !_player->z_axisposition ) _player->z_axisposition = movement_info.z; // calculate distance fallen uint32 falldistance = float2int32( _player->z_axisposition - movement_info.z ); /*if player is a rogue or druid(in cat form), then apply -17 modifier to fall distance. these checks need improving, low level rogue/druid should not receive this benefit*/ if( ( _player->getClass() == ROGUE ) || ( _player->GetShapeShift() == FORM_CAT ) ) { if( falldistance > 17 ) falldistance -=17; else falldistance = 1; } //checks that player has fallen more than 12 units, otherwise no damage will be dealt //falltime check is also needed here, otherwise sudden changes in Z axis position, such as using !recall, may result in death if( _player->isAlive() && !_player->GodModeCheat && falldistance > 12 && ( UNIXTIME >= _player->m_fallDisabledUntil ) && movement_info.FallTime > 1000 ) { // 1.7% damage for each unit fallen on Z axis over 13 uint32 health_loss = float2int32( float( _player->GetUInt32Value( UNIT_FIELD_MAXHEALTH ) * ( ( falldistance ) * 0.017 ) ) ); if( health_loss >= _player->GetUInt32Value( UNIT_FIELD_HEALTH ) ) health_loss = _player->GetUInt32Value( UNIT_FIELD_HEALTH ); _player->SendEnvironmentalDamageLog( _player->GetGUID(), DAMAGE_FALL, health_loss ); _player->DealDamage( _player, health_loss, 0, 0, 0 ); //_player->RemoveStealth(); // cebernic : why again? lost stealth by AURA_INTERRUPT_ON_ANY_DAMAGE_TAKEN already. } _player->z_axisposition = 0.0f; } else //whilst player is not falling, continuosly update Z axis position. //once player lands this will be used to determine how far he fell. if( !( movement_info.flags & MOVEFLAG_FALLING ) ) _player->z_axisposition = movement_info.z; } /************************************************************************/ /* Transporter Setup */ /************************************************************************/ if(!_player->m_lockTransportVariables) { if(_player->m_TransporterGUID && !movement_info.transGuid) { /* we left the transporter we were on */ if(_player->m_CurrentTransporter) { _player->m_CurrentTransporter->RemovePlayer(_player); _player->m_CurrentTransporter = NULL; } _player->m_TransporterGUID = 0; _player->SpeedCheatReset(); } else if(movement_info.transGuid) { if(!_player->m_TransporterGUID) { /* just walked into a transport */ if(_player->IsMounted()) _player->RemoveAura(_player->m_MountSpellId); _player->m_CurrentTransporter = objmgr.GetTransporter(GUID_LOPART(movement_info.transGuid)); if(_player->m_CurrentTransporter) _player->m_CurrentTransporter->AddPlayer(_player); /* set variables */ _player->m_TransporterGUID = movement_info.transGuid; _player->m_TransporterTime = movement_info.transTime; _player->m_TransporterX = movement_info.transX; _player->m_TransporterY = movement_info.transY; _player->m_TransporterZ = movement_info.transZ; } else { /* no changes */ _player->m_TransporterTime = movement_info.transTime; _player->m_TransporterX = movement_info.transX; _player->m_TransporterY = movement_info.transY; _player->m_TransporterZ = movement_info.transZ; } } /*float x = movement_info.x - movement_info.transX; float y = movement_info.y - movement_info.transY; float z = movement_info.z - movement_info.transZ; Transporter* trans = _player->m_CurrentTransporter; if(trans) sChatHandler.SystemMessageToPlr(_player, "Client t pos: %f %f\nServer t pos: %f %f Diff: %f %f", x,y, trans->GetPositionX(), trans->GetPositionY(), trans->CalcDistance(x,y,z), trans->CalcDistance(movement_info.x, movement_info.y, movement_info.z));*/ } /************************************************************************/ /* Anti-Speed Hack Checks */ /************************************************************************/ /************************************************************************/ /* Breathing System */ /************************************************************************/ _HandleBreathing(movement_info, _player, this); /************************************************************************/ /* Remove Spells */ /************************************************************************/ _player->RemoveAurasByInterruptFlag(AURA_INTERRUPT_ON_MOVEMENT); /************************************************************************/ /* Update our position in the server. */ /************************************************************************/ if( _player->m_CurrentCharm && _player->GetMapMgr() ) { Unit *cc = _player->GetMapMgr()->GetUnit( _player->m_CurrentCharm ); if( cc ) cc->SetPosition(movement_info.x, movement_info.y, movement_info.z, movement_info.orientation); } else { if(!_player->m_CurrentTransporter) { if( !_player->SetPosition(movement_info.x, movement_info.y, movement_info.z, movement_info.orientation) ) { _player->SetUInt32Value(UNIT_FIELD_HEALTH, 0); _player->KillPlayer(); } } else { _player->SetPosition(movement_info.x, movement_info.y, movement_info.z, movement_info.orientation + movement_info.transO, false); } } }