void ClusterInterface::HandleTransporterMapChange(WorldPacket & pck) { //remove when this is stable, ROFL DEBUG_LOG("Transport", "Handling clustered map change"); uint32 tentry, mapid; float x, y, z; pck >> tentry >> mapid >> x >> y >> z; Transporter* t = objmgr.GetTransporterByEntry(tentry); //we need to add to our map MapMgr* mgr = sInstanceMgr.GetMapMgr(mapid); LocationVector l; l.x = x; l.y = y; l.z = z; if (mgr == NULL) return; if (t->IsInWorld()) t->RemoveFromWorld(false); t->SetMapId(mapid); //don't start instantly, we start after eventclustermapchange is finished :P sEventMgr.RemoveEvents(t); //t->m_canmove = false; t->AddToWorld(mgr); sEventMgr.AddEvent(t, &Transporter::EventClusterMapChange, mapid, l, EVENT_UNK, 1, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT | EVENT_FLAG_MOVE_TO_WORLD_CONTEXT); }
void WorldSession::HandleMoveWorldportAckOpcode( WorldPacket & recv_data ) { GetPlayer()->SetPlayerStatus(NONE); if(_player->IsInWorld()) { // get outta here return; } sLog.outDebug( "WORLD: got MSG_MOVE_WORLDPORT_ACK." ); if(_player->m_CurrentTransporter && _player->GetMapId() != _player->m_CurrentTransporter->GetMapId()) { /* wow, our pc must really suck. */ Transporter * pTrans = _player->m_CurrentTransporter; float c_tposx = pTrans->GetPositionX() + _player->m_TransporterX; float c_tposy = pTrans->GetPositionY() + _player->m_TransporterY; float c_tposz = pTrans->GetPositionZ() + _player->m_TransporterZ; WorldPacket dataw(SMSG_NEW_WORLD, 20); dataw << pTrans->GetMapId() << c_tposx << c_tposy << c_tposz << _player->GetOrientation(); SendPacket(&dataw); } else { _player->m_TeleportState = 2; _player->AddToWorld(); } }
void TransporterNode::posCallback(const geometry_msgs::Twist::ConstPtr& msg) { ROS_INFO("Move dist [%f] & angle [%f]", msg->linear.x, msg->angular.z); trobot.moveDistance(msg->linear.x); trobot.moveAngle(msg->angular.z); publish_odom(); }
void TransporterRegistry::update_connections() { for (int i= 0, n= 0; n < nTransporters; i++){ Transporter * t = theTransporters[i]; if (!t) continue; n++; const NodeId nodeId = t->getRemoteNodeId(); switch(performStates[nodeId]){ case CONNECTED: case DISCONNECTED: break; case CONNECTING: if(t->isConnected()) report_connect(nodeId); break; case DISCONNECTING: if(!t->isConnected()) report_disconnect(nodeId, 0); break; } } }
void TransporterNode::velCallback(const geometry_msgs::Twist::ConstPtr& msg) { ROS_INFO("Move at vx [%f] & w [%f]", msg->linear.x, msg->angular.z); if (estopped) trobot.moveVelocity(0,0); else trobot.moveVelocity(msg->linear.x, msg->angular.z); publish_odom(); }
Uint32 TransporterRegistry::get_free_buffer(Uint32 node) const { Transporter *t; if(likely((t = theTransporters[node]) != 0)) { return t->get_free_buffer(); } return 0; }
void ObjectMgr::LoadTransporters() { #ifdef CLUSTERING return; #endif //!!!!!!!!!!!!! CATA !!!!!!!!!!! // this seems to deadlock maps, disabling it until properly implemented return; //!!!!!!!!!!!!! CATA !!!!!!!!!!! Log.Notice("ObjectMgr", "Loading Transports..."); QueryResult * QR = WorldDatabase.Query("SELECT entry FROM gameobject_names WHERE type = %u", GAMEOBJECT_TYPE_MO_TRANSPORT); if(!QR) return; int32 total = QR->GetRowCount(); do { uint32 entry = QR->Fetch()[0].GetUInt32(); //never do this ! // Transporter * pTransporter = new Transporter((uint64)HIGHGUID_TYPE_TRANSPORTER<<32 | entry); //wtf ? uint32 lowguid = objmgr.GenerateLowGuid( HIGHGUID_TYPE_TRANSPORTER ); Transporter * pTransporter = new Transporter(((uint64)HIGHGUID_TYPE_TRANSPORTER<<32) | lowguid); if(!pTransporter->CreateAsTransporter(entry, "")) { sLog.outDebug("Transporter %d failed creation for some reason.", entry); delete pTransporter; pTransporter = NULL; }else { AddTransport(pTransporter); QueryResult * result2 = WorldDatabase.Query("SELECT * FROM transport_creatures WHERE transport_entry = %u", entry); if(result2) { do { pTransporter->AddNPC(result2->Fetch()[1].GetUInt32(), result2->Fetch()[2].GetFloat(), result2->Fetch()[3].GetFloat(), result2->Fetch()[4].GetFloat(), result2->Fetch()[5].GetFloat()); } while (result2->NextRow()); delete result2; result2 = NULL; } } } while(QR->NextRow()); delete QR; QR = NULL; }
Transporter* ObjectMgr::LoadTransportInInstance(MapMgr *instance, uint32 goEntry, uint32 period) { auto gameobject_info = sMySQLStore.getGameObjectProperties(goEntry); if (gameobject_info == nullptr) { LOG_ERROR("Transport ID:%u, will not be loaded, gameobject_properties missing", goEntry); return NULL; } if (gameobject_info->type != GAMEOBJECT_TYPE_MO_TRANSPORT) { LOG_ERROR("Transport ID:%u, Name: %s, will not be loaded, gameobject_properties type wrong", goEntry, gameobject_info->name.c_str()); return NULL; } std::set<uint32> mapsUsed; Transporter* t = new Transporter((uint64)HIGHGUID_TYPE_TRANSPORTER << 32 | goEntry); // Generate waypoints if (!t->GenerateWaypoints(gameobject_info->mo_transport.taxi_path_id)) { LOG_ERROR("Transport ID:%u, Name: %s, failed to create waypoints", gameobject_info->entry, gameobject_info->name.c_str()); delete t; return NULL; } // Create Transporter if (!t->Create(goEntry, period)) { delete t; return NULL; } m_Transporters.insert(t); m_TransportersByInstanceIdMap[instance->GetInstanceID()].insert(t); AddTransport(t); // AddObject To World t->AddToWorld(instance); // correct incorrect instance id's t->SetInstanceID(instance->GetInstanceID()); t->SetMapId(t->GetMapId()); t->BuildStartMovePacket(instance); t->BuildStopMovePacket(instance); t->m_WayPoints.clear(); // Make transport stopped at server-side, movement will be handled by scripts LogDetail("Transport Handler : Spawned Transport Entry %u, map %u, instance id %u", goEntry, t->GetMapId(), t->GetInstanceID()); return t; }
void test_explorer() { #define TEST_EXPORT #define TEST_THREADS enum { queueBufferSize = 4096*8, }; char queueBuffer[queueBufferSize]; TransportParams* pParams; Transporter transporter; pParams = transporter.TransportDataInit( #ifdef TEST_EXPORT TRUE, #else FALSE, //importMode #endif queueBuffer, queueBufferSize, FS_FILE_SWAP, #ifdef TEST_EXPORT MULTI_PATHS_ZEXPORT #else MULTI_PATHS_ZIMPPORT #endif ); transporter.Init(pParams); #ifdef TEST_THREADS transporter.Start(); for (;;) { TransportStatus status; transporter.GetStatus(&status); _tprintf(TEXT("status %d expl %I64d xpot %I64d\n"), status.stateFlags, status.exploredSize, status.xportedSize); if (status.stateFlags & TransportStatus::xportingComplete) break; Sleep(500); } #else //TEST_THREADS #ifdef TEST_EXPORT transporter.ExploreThreadMain(); transporter.XportThreadMain(); #else transporter.XportThreadMain(); #endif #endif //TEST_THREADS transporter.Final(); transporter.TransportDataFinal(pParams); }
void ObjectMgr::LoadTransporters() { #ifdef CLUSTERING return; #endif Log.Notice("ObjectMgr", "Loading Transports..."); QueryResult * QR = WorldDatabase.Query("SELECT entry FROM gameobject_names WHERE type = %u", GAMEOBJECT_TYPE_MO_TRANSPORT); if(!QR) return; int64 total = QR->GetRowCount(); TransportersCount = total; uint32 entry = NULL; Transporter* pTransporter = NULL; do { entry = QR->Fetch()[0].GetUInt32(); pTransporter = new Transporter((uint64)HIGHGUID_TYPE_TRANSPORTER<<32 | entry); pTransporter->Init(); if(!pTransporter->CreateAsTransporter(entry, "")) { Log.Warning("ObjectMgr","Skipped invalid transporterid %d.", entry); pTransporter->Destruct(); pTransporter = NULL; } else { AddTransport(pTransporter); QueryResult * result2 = WorldDatabase.Query("SELECT * FROM transport_creatures WHERE transport_entry = %u", entry); if(result2) { do { pTransporter->AddNPC(result2->Fetch()[1].GetUInt32(), result2->Fetch()[2].GetFloat(), result2->Fetch()[3].GetFloat(), result2->Fetch()[4].GetFloat(), result2->Fetch()[5].GetFloat()); } while (result2->NextRow()); delete result2; } } } while(QR->NextRow()); delete QR; }
void ObjectMgr::LoadTransporters() { #ifdef CLUSTERING return; #endif Log.Notice("ObjectMgr", "Loading Transports..."); QueryResult * QR = WorldDatabase.Query("SELECT * FROM transport_data"); if (!QR) return; int64 total = QR->GetRowCount(); TransportersCount = total; do { uint32 entry = QR->Fetch()[0].GetUInt32(); int32 period = QR->Fetch()[2].GetInt32(); Transporter * pTransporter = new Transporter((uint64)HIGHGUID_TYPE_TRANSPORTER << 32 | entry); if (!pTransporter->CreateAsTransporter(entry, "", period)) { sLog.outError("Transporter %s failed creation for some reason.", QR->Fetch()[1].GetString()); delete pTransporter; } else { AddTransport(pTransporter); QueryResult * result2 = WorldDatabase.Query("SELECT * FROM transport_creatures WHERE transport_entry = %u", entry); if (result2) { do { pTransporter->AddNPC(result2->Fetch()[1].GetUInt32(), result2->Fetch()[2].GetFloat(), result2->Fetch()[3].GetFloat(), result2->Fetch()[4].GetFloat(), result2->Fetch()[5].GetFloat()); } while (result2->NextRow()); delete result2; } } } while (QR->NextRow()); delete QR; }
bool TransporterRegistry::connect_client(NdbMgmHandle *h) { DBUG_ENTER("TransporterRegistry::connect_client(NdbMgmHandle)"); Uint32 mgm_nodeid= ndb_mgm_get_mgmd_nodeid(*h); if(!mgm_nodeid) { g_eventLogger.error("%s: %d", __FILE__, __LINE__); return false; } Transporter * t = theTransporters[mgm_nodeid]; if (!t) { g_eventLogger.error("%s: %d", __FILE__, __LINE__); return false; } DBUG_RETURN(t->connect_client(connect_ndb_mgmd(h))); }
void ObjectMgr::LoadTransporters() { Log.Notice("TransporterHandler", "Start loading transport_data"); { const char* loadAllTransportData = "SELECT entry, name, period FROM transport_data"; QueryResult* result = WorldDatabase.Query(loadAllTransportData); if (!result) { Log.Error("TransporterHandler", "Query failed: %s", loadAllTransportData); return; } uint32 count = 0; do { Field* field = result->Fetch(); TransporterDataQueryResult dbResult; dbResult.entry = field[0].GetUInt32(); dbResult.name = field[1].GetString(); dbResult.period = field[2].GetUInt32(); GameObjectInfo* goInfo = GameObjectNameStorage.LookupEntry(dbResult.entry); if (goInfo == nullptr) { Log.Error("TransporterHandler", "Transporter gameobject %u not available in GameObjectNameStorage!", dbResult.entry); continue; } Transporter* pTransporter = new Transporter((uint64)HIGHGUID_TYPE_TRANSPORTER << 32 | dbResult.entry); pTransporter->SetInfo(goInfo); if (!pTransporter->CreateAsTransporter(dbResult.entry, "", dbResult.period)) { Log.Error("TransporterHandler", "Transporter %s failed creation for some reason.", dbResult.name.c_str()); delete pTransporter; } else { Log.Debug("TransporterHandler", "%s, Entry: %u, Period: %u loaded", dbResult.name.c_str(), dbResult.entry, dbResult.period); AddTransport(pTransporter); ++count; } } while (result->NextRow()); delete result; Log.Success("TransporterHandler", "%u transporters loaded from table transporter_data", count); } Log.Notice("TransporterHandler", "Start loading transport_creatures"); { const char* loadTransportPassengers = "SELECT transport_entry, creature_entry, position_x, position_y, position_z, orientation FROM transport_creatures"; bool success = false; QueryResult* result = WorldDatabase.Query(&success, loadTransportPassengers); if (!success) { Log.Error("TransporterHandler", "Query failed: %s", loadTransportPassengers); return; } uint32 count = 0; if (result) { do { Field* field = result->Fetch(); uint32 transport_entry = field[0].GetUInt32(); uint32 creature_entry = field[1].GetUInt32(); auto transporter = GetTransporterByEntry(transport_entry); if (transporter == nullptr) { Log.Error("TransporterHandler", "Could not find transporter %u for transport_creatures entry %u", transport_entry, creature_entry); continue; } TransporterCreaturesQueryResult dbResult; dbResult.transport_entry = field[0].GetUInt32(); dbResult.creature_entry = field[1].GetUInt32(); dbResult.position_x = field[2].GetFloat(); dbResult.position_y = field[3].GetFloat(); dbResult.position_z = field[4].GetFloat(); dbResult.orientation = field[5].GetFloat(); transporter->creature_transport_data.push_back(dbResult); transporter->AddNPC(dbResult.creature_entry, dbResult.position_x, dbResult.position_y, dbResult.position_z, dbResult.orientation); ++count; } while (result->NextRow()); delete result; Log.Success("TransporterHandler", "%u transport passengers from table transport_creatures loaded.", count); } } }
// run as own thread void TransporterRegistry::start_clients_thread() { int persist_mgm_count= 0; DBUG_ENTER("TransporterRegistry::start_clients_thread"); while (m_run_start_clients_thread) { NdbSleep_MilliSleep(100); persist_mgm_count++; if(persist_mgm_count==50) { ndb_mgm_check_connection(m_mgm_handle); persist_mgm_count= 0; } for (int i= 0, n= 0; n < nTransporters && m_run_start_clients_thread; i++){ Transporter * t = theTransporters[i]; if (!t) continue; n++; const NodeId nodeId = t->getRemoteNodeId(); switch(performStates[nodeId]){ case CONNECTING: if(!t->isConnected() && !t->isServer) { bool connected= false; /** * First, we try to connect (if we have a port number). */ if (t->get_s_port()) connected= t->connect_client(); /** * If dynamic, get the port for connecting from the management server */ if( !connected && t->get_s_port() <= 0) { // Port is dynamic int server_port= 0; struct ndb_mgm_reply mgm_reply; if(!ndb_mgm_is_connected(m_mgm_handle)) ndb_mgm_connect(m_mgm_handle, 0, 0, 0); if(ndb_mgm_is_connected(m_mgm_handle)) { int res= ndb_mgm_get_connection_int_parameter(m_mgm_handle, t->getRemoteNodeId(), t->getLocalNodeId(), CFG_CONNECTION_SERVER_PORT, &server_port, &mgm_reply); DBUG_PRINT("info",("Got dynamic port %d for %d -> %d (ret: %d)", server_port,t->getRemoteNodeId(), t->getLocalNodeId(),res)); if( res >= 0 ) { /** * Server_port == 0 just means that that a mgmt server * has not received a new port yet. Keep the old. */ if (server_port) t->set_s_port(server_port); } else if(ndb_mgm_is_connected(m_mgm_handle)) { g_eventLogger.info("Failed to get dynamic port to connect to: %d", res); ndb_mgm_disconnect(m_mgm_handle); } else { g_eventLogger.info("Management server closed connection early. " "It is probably being shut down (or has problems). " "We will retry the connection. %d %s %s line: %d", ndb_mgm_get_latest_error(m_mgm_handle), ndb_mgm_get_latest_error_desc(m_mgm_handle), ndb_mgm_get_latest_error_msg(m_mgm_handle), ndb_mgm_get_latest_error_line(m_mgm_handle) ); } } /** else * We will not be able to get a new port unless * the m_mgm_handle is connected. Note that not * being connected is an ok state, just continue * until it is able to connect. Continue using the * old port until we can connect again and get a * new port. */ } } break; case DISCONNECTING: if(t->isConnected()) t->doDisconnect(); break; default: break; } } } DBUG_VOID_RETURN; }
void game_loop(void) { //load font ALLEGRO_FONT *font = al_load_ttf_font("RobotoMono-Medium.ttf",12,0); //create floor array (will eventually make this a function) srand(time(NULL)); for (int x = 0; x < 16; x++) { //for each y value between 2 and 13 for (int y = 0; y < 16; y++) { randX = 6 + (rand() % (int)(12 - 6 + 1)); randY = 0 + (rand() % (int)(3 - 0 + 1)); //drawDungeonTile(randX, randY, x, y); floorArray [x] [y] [0] = randX; floorArray [x] [y] [1] = randY; } } Player p1; //(speed, friction, sprint accel, max speed) //default: p1.setMovement(1.4, .4, 1.8, 4); p1.setMovement(1.4, .4, 1.8, 3); p1.setPosition(tileSize * 7, tileSize * 12); p1.setCurrentRoom(111); p1.setInitial(tileSize,tileSize,240,240); p1.setH(tileSize); p1.setW(tileSize); p1.setAnimation(tileSize * 0, tileSize * 0,0,0,9,4,0); p1.canMove = true; p1.vincible = true; p1.blinking = false; p1.blinkTimer = 5; int tempBlinkTimer = p1.blinkTimer; p1.knockback = 0; p1.knockbackTimer = 0; p1.setBound(19,27,7,3, 14,8,9,24); //p1.setX(240); //p1.setY(240); p1.leavingTransport = 0; //init player prototypes void movePlayerUp(Player &p); void movePlayerDown(Player &p); void movePlayerLeft(Player &p); void movePlayerRight(Player &p); void sprintPlayer(Player &p); void maxSpeedPlayer(Player &p); void maxWalkSpeedPlayer(Player &p); void updatePlayer(Player &p); void collidePlayerWallX(Player &p, int obstacles [16][16]); void collidePlayerWallY(Player &p, int obstacles [16][16]); void collidePlayerMonster(Player &p, Monster m[]); void drawPlayer(Player &p); void resetPlayerAnimation(Player &p); //load current room map Room currentRoom; currentRoom.getRoom(p1.getCurrentRoom()); //load all objects objectArray currentArray; currentArray.getObjects(p1.getCurrentRoom()); //load current room transporters Transporter currentTrans; currentTrans.exitNumber = 0; //init monsters prototypes Monster currentMonsters[numMonsters]; getMonsters(currentMonsters, currentArray.array); void getMonsters (Monster m[], int array[][16]); void drawMonsters (Monster m[]); void collideMonsterWallX(Monster m[], int obstacles [16][16]); void collideMonsterWallY(Monster m[], int obstacles [16][16]); void updateMonstersX (Monster currentMonsters[]); void updateMonstersY (Monster currentMonsters[]); void seekMonsters (Monster m[], Player p); int monsterDebug = 1; //load current room's monsters //currentMonsters.getObjects(p1.getCurrentRoom()); int vincibleTimer = 0; bool showHitboxes = false; al_start_timer(timer); while (!done) { ALLEGRO_EVENT event; al_wait_for_event(event_queue, &event); if (event.type == ALLEGRO_EVENT_TIMER) { if(key[keyW]) { movePlayerUp(p1); } else if(key[keyS]) { movePlayerDown(p1); } if(key[keyA]) { movePlayerLeft(p1); } else if(key[keyD]) { movePlayerRight(p1); } if(!(key[keyW] || key[keyA] ||key[keyS] ||key[keyD])) { resetPlayerAnimation(p1); } if(key[keyShift] && (key[keyW] || key[keyA] ||key[keyS] ||key[keyD])) { sprintPlayer(p1); maxSpeedPlayer(p1); } else { maxWalkSpeedPlayer(p1); } //Monster movement and wall collisions seekMonsters(currentMonsters,p1); updateMonstersX(currentMonsters); collideMonsterWallX(currentMonsters,currentRoom.array); updateMonstersY(currentMonsters); collideMonsterWallY(currentMonsters,currentRoom.array); redraw = true; //update player position p1.setX(p1.getX() + p1.getDx()); collidePlayerMonster(p1,currentMonsters); //printf("player DX: %f\n",p1.getDx()); //printf("player DY: %f\n",p1.getDy()); //X axis //detect and respond to collision with obstacles collidePlayerWallX(p1,currentRoom.array); if(p1.canMove) { p1.setDx(p1.getDx() * p1.getFriction()); } //knockback timer //Y axis p1.setY(p1.getY() + p1.getDy()); collidePlayerWallY(p1,currentRoom.array); p1.setDy(p1.getDy() * p1.getFriction()); //if able to transport if (p1.leavingTransport == 0) { //check for collisions with transporter currentTrans.exitNumber = currentTrans.playerTransCollision(p1.getX(), p1.getY(),currentArray.array); if (currentTrans.exitNumber) { currentTrans.fromNumber = p1.getCurrentRoom(); p1.leavingTransport = 1; } } //if transporting if ( p1.leavingTransport == 1) { //set room to move to p1.setCurrentRoom(currentTrans.exitNumber); currentRoom.getRoom(p1.getCurrentRoom()); currentArray.getObjects(p1.getCurrentRoom()); getMonsters(currentMonsters, currentArray.array); //must set player's location to the location of the exit portal in the new room currentTrans.getDestination(currentArray.array); p1.setX(currentTrans.destination[0] + tileSize/2); p1.setY(currentTrans.destination[1] + tileSize/2); currentTrans.destination[0] = 0; currentTrans.destination[1] = 0; p1.leavingTransport = 0; } //functions for drawing the player (will need to go elsewhere eventually) //invincible timer if (p1.vincible == false) { vincibleTimer ++; tempBlinkTimer --; p1.blinking = true; //printf("p1 blinking? %d, %d\n",p1.blinking, tempBlinkTimer); if (tempBlinkTimer < 0) { p1.blinking = false; if ( tempBlinkTimer == p1.blinkTimer * (-3)) { tempBlinkTimer = p1.blinkTimer; } } if (vincibleTimer == invincibleTime) { p1.vincible = true; p1.blinking = false; vincibleTimer = 0; //printf ("vincible Again \n"); } } //animation frame counter redraw = true; } //key pressed down else if (event.type == ALLEGRO_EVENT_KEY_DOWN) { switch (event.keyboard.keycode) { case ALLEGRO_KEY_ESCAPE: done = true; case ALLEGRO_KEY_W: key[keyW] = true; break; case ALLEGRO_KEY_A: key[keyA] = true; break; case ALLEGRO_KEY_S: key[keyS] = true; break; case ALLEGRO_KEY_D: key[keyD] = true; break; case ALLEGRO_KEY_LSHIFT: key[keyShift] = true; break; } } //key released else if (event.type == ALLEGRO_EVENT_KEY_UP) { switch (event.keyboard.keycode) { case ALLEGRO_KEY_W: key[keyW] = false; break; case ALLEGRO_KEY_A: key[keyA] = false; break; case ALLEGRO_KEY_S: key[keyS] = false; break; case ALLEGRO_KEY_D: key[keyD] = false; break; case ALLEGRO_KEY_LSHIFT: key[keyShift] = false; break; } } else if(event.type == ALLEGRO_EVENT_MOUSE_AXES || ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY) { crosshair_x = event.mouse.x - crosshairSize/2; crosshair_y = event.mouse.y - crosshairSize/2; } if (redraw && al_is_event_queue_empty(event_queue)) { redraw = false; //Clear screen to green al_clear_to_color(al_map_rgb(0, 0, 0)); //update_graphics(); //graphics that will always be there drawDungeon(floorArray,currentRoom.array); if (transDebug) currentTrans.drawTransporters(currentArray.array); drawMonsters(currentMonsters); //Monster debug hitbox if (showHitboxes) { for (int i = 0; i < numMonsters; i ++) { if (currentMonsters[i].isLive == 1) { //al_draw_rectangle(BBBitmap, currentMonsters[i].getX() + currentMonsters[i].getBoundOffsetW(), currentMonsters[i].getY() + currentMonsters[i].getBoundOffsetH(), 0); al_draw_rectangle(currentMonsters[i].getX() + currentMonsters[i].getBoundOffsetW(), currentMonsters[i].getY() + currentMonsters[i].getBoundOffsetH(), currentMonsters[i].getX() + currentMonsters[i].getBoundOffsetW() + currentMonsters[i].getBoundW(), currentMonsters[i].getY() + currentMonsters[i].getBoundOffsetH() + currentMonsters[i].getBoundH(), al_map_rgb(255,0,0),1); al_draw_rectangle(currentMonsters[i].getX() + currentMonsters[i].getWallOffsetW(), currentMonsters[i].getY() + currentMonsters[i].getWallOffsetH(), currentMonsters[i].getX() + currentMonsters[i].getWallOffsetW() + currentMonsters[i].getWallW(), currentMonsters[i].getY() + currentMonsters[i].getWallOffsetH() + currentMonsters[i].getWallH(), al_map_rgb(0,255,0),1); } } } if (p1.blinking == false) { drawPlayer(p1); } //player debug hitbox if (showHitboxes) { al_draw_rectangle(p1.getX() + p1.getBoundOffsetW(), p1.getY() + p1.getBoundOffsetH(), p1.getX() + p1.getBoundOffsetW() + p1.getBoundW(), p1.getY() + p1.getBoundOffsetH() + p1.getBoundH(), al_map_rgb(255,0,0),1); al_draw_rectangle(p1.getX() + p1.getWallOffsetW(), p1.getY() + p1.getWallOffsetH(), p1.getX() + p1.getWallOffsetW() + p1.getWallW(), p1.getY() + p1.getWallOffsetH() + p1.getWallH(), al_map_rgb(0,255,0),1); } al_draw_text(font, al_map_rgb(255,255,255),0,tileSize*15,ALLEGRO_ALIGN_LEFT,"TEXT!"); //al_draw_bitmap(crosshair, crosshair_x, crosshair_y, 0); al_flip_display(); } } }
int main(int argc, char ** argv){ //VideoSource vs(false, "./Various.avi"); VideoSource vs(true, ""); vs.enableDisplayWindow(); SupportedImageWidths siw = W512; // Left to Right is bottom layer to top //uint centroid_counts[] = {3,3,4,3,3,3,3,5}; uint centroid_counts[] = {4,3,5,3,3,2,3,4}; bool isUniform = true; DestinNetworkAlt * network = new DestinNetworkAlt(siw, 8, centroid_counts, isUniform); Transporter t; vs.grab();//throw away first frame in case its garbage int frameCount = 0; while(vs.grab()){ frameCount++; t.setSource(vs.getOutput()); t.transport(); //move video from host to card testNan(t.getDest(), 512*512); network->doDestin(t.getDest()); if(frameCount % 2 != 0 ){ //only print every 2rd so display is not so jumpy printFPS(false); continue; } // Old clear screen method //printf("\033[2J"); // New clear screen method (might give less flickering...?) printf("\033[2J\033[1;1H"); printf("Frame: %i\n", frameCount); printFPS(true); int layer = 1; Node & n = *network->getNode(layer,0,0); printf("Node %i,0,0 winner: %i\n",layer, n.winner); printf("Node centroids: %i\n", n.nb); printf("Node starv:"); printFloatArray(n.starv, n.nb); printf("Starv coef: %f \n", n.starvCoeff); printf("\n"); // 2013.4.5 // CZT // //printf("layer %i node 0 centroid locations:\n", layer); //network->printNodeCentroidPositions(layer, 0, 0); for(int l = 0 ; l < 8 ; l++){ printf("belief graph layer: %i\n",l); network->printBeliefGraph(l,0,0); } } delete network; return 0; }
void WorldSession::FullLogin(Player* plr) { DEBUG_LOG("WorldSession", "Fully loading player %u", plr->GetLowGUID()); SetPlayer(plr); m_MoverWoWGuid.Init(plr->GetGUID()); // copy to movement array plr->movement_packet[0] = m_MoverWoWGuid.GetNewGuidMask(); memcpy(&plr->movement_packet[1], m_MoverWoWGuid.GetNewGuid(), m_MoverWoWGuid.GetNewGuidLen()); WorldPacket datab(MSG_SET_DUNGEON_DIFFICULTY, 20); datab << plr->iInstanceType; datab << uint32(0x01); datab << uint32(0x00); SendPacket(&datab); WorldPacket datac(MSG_SET_RAID_DIFFICULTY, 20); datac << plr->iRaidType; datac << uint32(0x01); datac << uint32(0x00); SendPacket(&datac); // Send first line of MOTD WorldPacket datat(SMSG_MOTD, sizeof(sWorld.GetMotd()) + 4); datat << uint32(0x04); datat << sWorld.GetMotd(); SendPacket(&datat); /* world preload */ packetSMSG_LOGIN_VERIFY_WORLD vwpck; vwpck.MapId = plr->GetMapId(); vwpck.O = plr->GetOrientation(); vwpck.X = plr->GetPositionX(); vwpck.Y = plr->GetPositionY(); vwpck.Z = plr->GetPositionZ(); OutPacket( SMSG_LOGIN_VERIFY_WORLD, sizeof(packetSMSG_LOGIN_VERIFY_WORLD), &vwpck ); ////////////////////////////////////////////////////////////////////////////////////////////////////// // send voicechat state - active/inactive // // {SERVER} Packet: (0x03C7) UNKNOWN PacketSize = 2 // |------------------------------------------------|----------------| // |00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF| // |------------------------------------------------|----------------| // |02 01 |.. | // ------------------------------------------------------------------- // // // Old packetdump is OLD. This is probably from 2.2.0 (that was the patch when it was added to wow)! // ////////////////////////////////////////////////////////////////////////////////////////////////////// plr->UpdateAttackSpeed(); // Make sure our name exists (for premade system) PlayerInfo * info = objmgr.GetPlayerInfo(plr->GetLowGUID()); if(info == NULL) { info = new PlayerInfo; memset(info, 0, sizeof(PlayerInfo)); info->cl = plr->getClass(); info->gender = plr->getGender(); info->guid = plr->GetLowGUID(); info->name = strdup(plr->GetName()); info->lastLevel = plr->getLevel(); info->lastOnline = UNIXTIME; info->lastZone = plr->GetZoneId(); info->race = plr->getRace(); info->team = plr->GetTeam(); objmgr.AddPlayerInfo(info); } plr->m_playerInfo = info; if(plr->m_playerInfo->guild) { plr->m_uint32Values[PLAYER_GUILDID] = plr->m_playerInfo->guild->GetGuildId(); plr->m_uint32Values[PLAYER_GUILDRANK] = plr->m_playerInfo->guildRank->iId; } for(uint32 z = 0; z < NUM_ARENA_TEAM_TYPES; ++z) { if(_player->m_playerInfo->arenaTeam[z] != NULL) { _player->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (z*7), _player->m_playerInfo->arenaTeam[z]->m_id); if(_player->m_playerInfo->arenaTeam[z]->m_leader == _player->GetLowGUID()) _player->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (z*7) + 1, 0); else _player->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (z*7) + 1, 1); } } info->m_loggedInPlayer = plr; // account data == UI config if(sWorld.m_useAccountData) { WorldPacket data(SMSG_ACCOUNT_DATA_TIMES, 4+1+4+8*4); MD5Hash md5hash; data << uint32(UNIXTIME) << uint8(1) << uint32(0xEA); for (int i = 0; i < 8; i++) { AccountDataEntry* acct_data = GetAccountData(i); if(0xEA & (1 << i)) data << uint32(acct_data->Time); md5hash.Initialize(); md5hash.UpdateData((const uint8*)acct_data->data, acct_data->sz); md5hash.Finalize(); } SendPacket(&data); } else { WorldPacket data(SMSG_ACCOUNT_DATA_TIMES, 4+1+4+8*4); MD5Hash md5hash; data << uint32(UNIXTIME) << uint8(1) << uint32(0xEA); for (int i = 0; i < 8; i++) { if(0xEA & (1 << i)) data << uint32(0); AccountDataEntry* acct_data = GetAccountData(i); if(acct_data) { md5hash.Initialize(); md5hash.UpdateData((const uint8*)acct_data->data, acct_data->sz); md5hash.Finalize(); } } SendPacket(&data); } // Set TIME OF LOGIN CharacterDatabase.Execute("UPDATE characters SET online = 1 WHERE guid = %u" , plr->GetLowGUID()); _player->ResetTitansGrip(); bool enter_world = true; #ifndef CLUSTERING // Find our transporter and add us if we're on one. if(plr->m_TransporterGUID != 0) { Transporter* pTrans = objmgr.GetTransporter(GUID_LOPART(plr->m_TransporterGUID)); if(pTrans) { if(plr->isDead()) { plr->RemoteRevive(); } float c_tposx = pTrans->GetPositionX() + plr->m_transportPosition->x; float c_tposy = pTrans->GetPositionY() + plr->m_transportPosition->y; float c_tposz = pTrans->GetPositionZ() + plr->m_transportPosition->z; if(plr->GetMapId() != pTrans->GetMapId()) // loaded wrong map { plr->SetMapId(pTrans->GetMapId()); WorldPacket dataw(SMSG_NEW_WORLD, 20); dataw << pTrans->GetMapId() << c_tposx << c_tposy << c_tposz << plr->GetOrientation(); SendPacket(&dataw); // shit is sent in worldport ack. enter_world = false; } plr->SetPosition(c_tposx, c_tposy, c_tposz, plr->GetOrientation(), false); plr->m_CurrentTransporter = pTrans; pTrans->AddPlayer(plr); } } #endif if(plr->m_CurrentVehicle) plr->m_CurrentVehicle->RemovePassenger(plr); DEBUG_LOG( "WorldSession","Player %s logged in.", plr->GetName()); if(plr->GetTeam() == 1) sWorld.HordePlayers++; else sWorld.AlliancePlayers++; if(plr->m_FirstLogin && !HasGMPermissions()) OutPacket(SMSG_TRIGGER_CINEMATIC, 4, &plr->myRace->cinematic_id); DEBUG_LOG( "WorldSession","Created new player for existing players (%s)", plr->GetName() ); // Login time, will be used for played time calc plr->m_playedtime[2] = uint32(UNIXTIME); //Issue a message telling all guild members that this player has signed on if(plr->IsInGuild()) { Guild *pGuild = plr->m_playerInfo->guild; if(pGuild) { WorldPacket data(50); data.Initialize(SMSG_GUILD_EVENT); data << uint8(GUILD_EVENT_MOTD); data << uint8(0x01); if(pGuild->GetMOTD()) data << pGuild->GetMOTD(); else data << uint8(0); SendPacket(&data); pGuild->LogGuildEvent(GUILD_EVENT_HASCOMEONLINE, 1, plr->GetName()); } } // Send online status to people having this char in friendlist (excluding GM's) if(!HasGMPermissions()) _player->Social_TellFriendsOnline(); // send friend list (for ignores) _player->Social_SendFriendList(7); // Send revision (if enabled) #ifdef WIN32 // _player->BroadcastMessage("Core server: ArcEmu %s r%u/%s-Windows-%s (www.github.com/ArcEmudev)", MSG_COLOR_WHITE, BUILD_TAG, BUILD_REVISION, CONFIG, ARCH, MSG_COLOR_LIGHTBLUE); #else // _player->BroadcastMessage("Core server: ArcEmu %s r%u/%s-%s (www.github.com/ArcEmudev)", MSG_COLOR_WHITE, BUILD_TAG, BUILD_REVISION, PLATFORM_TEXT, ARCH, MSG_COLOR_LIGHTBLUE); #endif // Bugs _player->BroadcastMessage("Bugs: %s%s", MSG_COLOR_LIGHTBLUE, BUG_TRACKER); if(sWorld.SendStatsOnJoin) { _player->BroadcastMessage("Online Players: %s%u |rPeak: %s%u|r Accepted Connections: %s%u", MSG_COLOR_WHITE, sWorld.GetSessionCount(), MSG_COLOR_WHITE, sWorld.PeakSessionCount, MSG_COLOR_WHITE, sWorld.mAcceptedConnections); _player->BroadcastMessage("Server Uptime: |r%s", sWorld.GetUptimeString().c_str()); } // send to gms if(HasGMPermissions()) sWorld.SendMessageToGMs(this, "%s %s (%s) is now online.", CanUseCommand('z') ? "Admin" : "GameMaster", _player->GetName(), GetAccountNameS(), GetPermissions()); //Set current RestState if( plr->m_isResting) // We are in a resting zone, turn on Zzz plr->ApplyPlayerRestState(true); //Check if there is a time difference between lastlogoff and now if( plr->m_timeLogoff > 0 && plr->GetUInt32Value(UNIT_FIELD_LEVEL) < plr->GetUInt32Value(PLAYER_FIELD_MAX_LEVEL)) // if timelogoff = 0 then it's the first login { uint32 currenttime = (uint32)UNIXTIME; uint32 timediff = currenttime - plr->m_timeLogoff; //Calculate rest bonus if( timediff > 0 ) plr->AddCalculatedRestXP(timediff); } sHookInterface.OnEnterWorld2(_player); if(info->m_Group) info->m_Group->Update(); // Retroactive: Level achievement if(plr->getLevel() > 10 && !GetPermissions()) { // Retroactive: Level achievement _player->GetAchievementInterface()->HandleAchievementCriteriaLevelUp( _player->getLevel() ); // Send achievement data! if( _player->GetAchievementInterface()->HasAchievements() ) { WorldPacket * data = _player->GetAchievementInterface()->BuildAchievementData(); _player->CopyAndSendDelayedPacket(data); delete data; } } if(enter_world && !_player->GetMapMgr()) plr->AddToWorld(); objmgr.AddPlayer(_player); }
void ObjectMgr::LoadTransports() { LogNotice("TransportHandler : Start creating transports..."); { uint32_t createCount = 0; for (auto it : sMySQLStore._transportDataStore) { GameObjectProperties const* gameobject_info = sMySQLStore.getGameObjectProperties(it.first); std::set<uint32> mapsUsed; Transporter* pTransporter = new Transporter((uint64)HIGHGUID_TYPE_TRANSPORTER << 32 | it.first); if (pTransporter->GenerateWaypoints(gameobject_info->mo_transport.taxi_path_id) == false) { LOG_ERROR("Transport entry: %u, failed to create waypoints", it.first); delete pTransporter; continue; } if (pTransporter->Create(it.first, it.second.period) == false) { delete pTransporter; continue; } pTransporter->AddToWorld(); m_Transporters.insert(pTransporter); AddTransport(pTransporter); for (std::set<uint32>::const_iterator i = mapsUsed.begin(); i != mapsUsed.end(); ++i) { m_TransportersByMap[*i].insert(pTransporter); } ++createCount; } LogDetail("Transporter Handler : Created %u transports", createCount); } LogNotice("TransportHandler : Start populating transports with creatures..."); { for (auto it : sMySQLStore._transportCreaturesStore) { for (ObjectMgr::TransporterSet::iterator itr = m_Transporters.begin(); itr != m_Transporters.end(); ++itr) { if ((*itr)->getEntry() == it.second.transportEntry) { TransportSpawn spawn{ it.second.guid, it.second.entry, it.second.transportEntry, it.second.transportOffsetX, it.second.transportOffsetY, it.second.transportOffsetZ, it.second.transportOffsetO, it.second.animation }; (*itr)->AddCreature(spawn); break; } } } for (auto transport : m_Transporters) { transport->RespawnCreaturePassengers(); } } }
void TransporterNode::publish_odom() { // store the current pose prevPose.x = cur_x; prevPose.y = cur_y; prevPose.theta = cur_theta; // calculate the new pose double distance, angle; trobot.getDisplacement(&distance, &angle); cur_theta += angle; cur_x += distance * cos(cur_theta); cur_y += distance * sin(cur_theta); ROS_DEBUG("PREVIOUS x = [%f], y = [%f], theta = [%f]\n", prevPose.x, prevPose.y, prevPose.theta); ROS_DEBUG("CURRENT x = [%f], y = [%f], theta = [%f]\n", cur_x, cur_y, cur_theta); current_time = ros::Time::now(); double dt = (current_time - last_time).toSec(); // convert rotation about z into quaternion geometry_msgs::Quaternion odom_quat; odom_quat.z = sin(cur_theta/2.0); odom_quat.w = cos(cur_theta/2.0); //next, we'll publish the odometry message over ROS nav_msgs::Odometry odom; odom.header.stamp = current_time; odom.header.frame_id = "odom"; odom.child_frame_id = "base_footprint"; //set the position (with respect to header.frame) odom.pose.pose.position.x = cur_x; odom.pose.pose.position.y = cur_y; odom.pose.pose.position.z = 0.0; odom.pose.pose.orientation = odom_quat; odom.pose.covariance = boost::array<double, 36>{{1e-3, 0, 0, 0, 0, 0, 0, 1e-3, 0, 0, 0, 0, 0, 0, 1e6, 0, 0, 0, 0, 0, 0, 1e6, 0, 0, 0, 0, 0, 0, 1e6, 0, 0, 0, 0, 0, 0, 1e-3}}; //set the velocity (with respect to child_frame) odom.twist.twist.linear.x = distance/dt; odom.twist.twist.angular.z = angle/dt; odom.twist.covariance = boost::array<double, 36>{{1e-3, 0, 0, 0, 0, 0, 0, 1e-3, 0, 0, 0, 0, 0, 0, 1e6, 0, 0, 0, 0, 0, 0, 1e6, 0, 0, 0, 0, 0, 0, 1e6, 0, 0, 0, 0, 0, 0, 1e-3}}; //publish the message odom_pub.publish(odom); // publish joint state in order to show the continuous joints (wheels) in tf sensor_msgs::JointState js; js.header.stamp=current_time; js.name.resize(2); js.position.resize(2); js.name[0]="left_wheel_joint"; js.name[1]="right_wheel_joint"; js.position[0]=0; js.position[1]=0; js_pub.publish(js); last_time = current_time; } //void TransporterNode::publish_odom()
void WorldSession::FullLogin(Player * plr) { Log.Debug("WorldSession", "Fully loading player %u", plr->GetLowGUID()); SetPlayer(plr); m_MoverWoWGuid.Init(plr->GetGUID()); // copy to movement array movement_packet[0] = m_MoverWoWGuid.GetNewGuidMask(); memcpy(&movement_packet[1], m_MoverWoWGuid.GetNewGuid(), m_MoverWoWGuid.GetNewGuidLen()); #ifndef USING_BIG_ENDIAN StackWorldPacket<20> datab(CMSG_DUNGEON_DIFFICULTY); #else WorldPacket datab(CMSG_DUNGEON_DIFFICULTY, 20); #endif datab << plr->iInstanceType; datab << uint32(0x01); datab << uint32(0x00); SendPacket(&datab); /* world preload */ packetSMSG_LOGIN_VERIFY_WORLD vwpck; vwpck.MapId = plr->GetMapId(); vwpck.O = plr->GetOrientation(); vwpck.X = plr->GetPositionX(); vwpck.Y = plr->GetPositionY(); vwpck.Z = plr->GetPositionZ(); OutPacket( SMSG_LOGIN_VERIFY_WORLD, sizeof(packetSMSG_LOGIN_VERIFY_WORLD), &vwpck ); // send voicechat state - active/inactive /* {SERVER} Packet: (0x03C7) UNKNOWN PacketSize = 2 |------------------------------------------------|----------------| |00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF| |------------------------------------------------|----------------| |02 01 |.. | ------------------------------------------------------------------- */ #ifdef VOICE_CHAT datab.Initialize(SMSG_VOICE_SYSTEM_STATUS); datab << uint8(2) << uint8(sVoiceChatHandler.CanUseVoiceChat() ? 1 : 0); SendPacket(&datab); #else datab.Initialize(SMSG_VOICE_SYSTEM_STATUS); datab << uint8(2) << uint8(0); #endif plr->UpdateAttackSpeed(); /*if(plr->getLevel()>70) plr->SetUInt32Value(UNIT_FIELD_LEVEL,70);*/ // enable trigger cheat by default plr->triggerpass_cheat = HasGMPermissions(); // Make sure our name exists (for premade system) PlayerInfo * info = objmgr.GetPlayerInfo(plr->GetLowGUID()); if(info == 0) { info = new PlayerInfo; info->cl = plr->getClass(); info->gender = plr->getGender(); info->guid = plr->GetLowGUID(); info->name = strdup(plr->GetName()); info->lastLevel = plr->getLevel(); info->lastOnline = UNIXTIME; info->lastZone = plr->GetZoneId(); info->race = plr->getRace(); info->team = plr->GetTeam(); info->guild=NULL; info->guildRank=NULL; info->guildMember=NULL; info->m_Group=0; info->subGroup=0; objmgr.AddPlayerInfo(info); } plr->m_playerInfo = info; if(plr->m_playerInfo->guild) { plr->m_uint32Values[PLAYER_GUILDID] = plr->m_playerInfo->guild->GetGuildId(); plr->m_uint32Values[PLAYER_GUILDRANK] = plr->m_playerInfo->guildRank->iId; } info->m_loggedInPlayer = plr; // account data == UI config #ifndef USING_BIG_ENDIAN StackWorldPacket<128> data(SMSG_ACCOUNT_DATA_MD5); #else WorldPacket data(SMSG_ACCOUNT_DATA_MD5, 128); #endif MD5Hash md5hash; for (int i = 0; i < 8; i++) { AccountDataEntry* acct_data = GetAccountData(i); if (!acct_data->data) { data << uint64(0) << uint64(0); // Nothing. continue; } md5hash.Initialize(); md5hash.UpdateData((const uint8*)acct_data->data, acct_data->sz); md5hash.Finalize(); #ifndef USING_BIG_ENDIAN data.Write(md5hash.GetDigest(), MD5_DIGEST_LENGTH); #else data.append(md5hash.GetDigest(), MD5_DIGEST_LENGTH); #endif } SendPacket(&data); // Set TIME OF LOGIN CharacterDatabase.Execute ( "UPDATE characters SET online = 1 WHERE guid = %u" , plr->GetLowGUID()); bool enter_world = true; #ifndef CLUSTERING // Find our transporter and add us if we're on one. if(plr->m_TransporterGUID != 0) { Transporter * pTrans = objmgr.GetTransporter(GUID_LOPART(plr->m_TransporterGUID)); if(pTrans) { if(plr->isDead()) { plr->ResurrectPlayer(); plr->SetUInt32Value(UNIT_FIELD_HEALTH, plr->GetUInt32Value(UNIT_FIELD_MAXHEALTH)); plr->SetUInt32Value(UNIT_FIELD_POWER1, plr->GetUInt32Value(UNIT_FIELD_MAXPOWER1)); } float c_tposx = pTrans->GetPositionX() + plr->m_TransporterX; float c_tposy = pTrans->GetPositionY() + plr->m_TransporterY; float c_tposz = pTrans->GetPositionZ() + plr->m_TransporterZ; if(plr->GetMapId() != pTrans->GetMapId()) // loaded wrong map { plr->SetMapId(pTrans->GetMapId()); #ifndef USING_BIG_ENDIAN StackWorldPacket<20> dataw(SMSG_NEW_WORLD); #else WorldPacket dataw(SMSG_NEW_WORLD, 20); #endif dataw << pTrans->GetMapId() << c_tposx << c_tposy << c_tposz << plr->GetOrientation(); SendPacket(&dataw); // shit is sent in worldport ack. enter_world = false; } plr->SetPosition(c_tposx, c_tposy, c_tposz, plr->GetOrientation(), false); plr->m_CurrentTransporter = pTrans; pTrans->AddPlayer(plr); } } #endif Log.Debug("Login", "Player %s logged in.", plr->GetName()); if(plr->GetTeam() == 1) sWorld.HordePlayers++; else sWorld.AlliancePlayers++; if(plr->m_FirstLogin && !HasGMPermissions()) { uint32 racecinematic = plr->myRace->cinematic_id; #ifdef USING_BIG_ENDIAN swap32(&racecinematic); #endif OutPacket(SMSG_TRIGGER_CINEMATIC, 4, &racecinematic); } sLog.outDetail( "WORLD: Created new player for existing players (%s)", plr->GetName() ); // Login time, will be used for played time calc plr->m_playedtime[2] = (uint32)UNIXTIME; //Issue a message telling all guild members that this player has signed on if(plr->IsInGuild()) { Guild *pGuild = plr->m_playerInfo->guild; if(pGuild) { WorldPacket data(50); data.Initialize(SMSG_GUILD_EVENT); data << uint8(GUILD_EVENT_MOTD); data << uint8(0x01); if(pGuild->GetMOTD()) data << pGuild->GetMOTD(); else data << uint8(0); SendPacket(&data); pGuild->LogGuildEvent(GUILD_EVENT_HASCOMEONLINE, 1, plr->GetName()); } } // Send online status to people having this char in friendlist _player->Social_TellFriendsOnline(); // send friend list (for ignores) _player->Social_SendFriendList(7); // Send MOTD _player->BroadcastMessage(sWorld.GetMotd()); // Send revision (if enabled) #ifdef WIN32 _player->BroadcastMessage("Server: %sAscent %s r%u/%s-Win-%s %s(www.ascentemu.com)", MSG_COLOR_WHITE, BUILD_TAG, BUILD_REVISION, CONFIG, ARCH, MSG_COLOR_LIGHTBLUE); #else _player->BroadcastMessage("Server: %sAscent %s r%u/%s-%s %s(www.ascentemu.com)", MSG_COLOR_WHITE, BUILD_TAG, BUILD_REVISION, PLATFORM_TEXT, ARCH, MSG_COLOR_LIGHTBLUE); #endif if(sWorld.SendStatsOnJoin) { _player->BroadcastMessage("Online Players: %s%u |rPeak: %s%u|r Accepted Connections: %s%u", MSG_COLOR_WHITE, sWorld.GetSessionCount(), MSG_COLOR_WHITE, sWorld.PeakSessionCount, MSG_COLOR_WHITE, sWorld.mAcceptedConnections); } //Set current RestState if( plr->m_isResting) // We are resting at an inn , turn on Zzz plr->ApplyPlayerRestState(true); //Calculate rest bonus if there is time between lastlogoff and now if( plr->m_timeLogoff > 0 && plr->GetUInt32Value(UNIT_FIELD_LEVEL) < plr->GetUInt32Value(PLAYER_FIELD_MAX_LEVEL)) // if timelogoff = 0 then it's the first login { uint32 currenttime = (uint32)UNIXTIME; uint32 timediff = currenttime - plr->m_timeLogoff; //Calculate rest bonus if( timediff > 0 ) plr->AddCalculatedRestXP(timediff); } #ifdef CLUSTERING plr->SetInstanceID(forced_instance_id); plr->SetMapId(forced_map_id); #else sHookInterface.OnEnterWorld2(_player); #endif if(info->m_Group) info->m_Group->Update(); if(enter_world && !_player->GetMapMgr()) { plr->AddToWorld(); } objmgr.AddPlayer(_player); }
bool ChatHandler::HandleSummonCommand(const char* args, WorldSession *m_session) { if(!*args) return false; sGMLog.writefromsession(m_session, "summoned %s on map %u, %f %f %f", args, m_session->GetPlayer()->GetMapId(),m_session->GetPlayer()->GetPositionX(),m_session->GetPlayer()->GetPositionY(),m_session->GetPlayer()->GetPositionZ()); Player * plr = m_session->GetPlayer(); Player *chr = objmgr.GetPlayer(args, false); if( chr && chr->m_isGmInvisible < 2 ) { // send message to user char buf[256]; char buf0[256]; if( chr->IsBeingTeleported() == true ) { snprintf((char*)buf,256, "%s is already being teleported.", chr->GetName()); SystemMessage(m_session, buf); return true; } if(!chr->RemoveTransporterStatus()) { char buff[256]; snprintf((char*)buf,256, "%s already being teleported.", chr->GetName()); SystemMessage(m_session, buff); return true; } if( plr->RS_getAccess() < chr->RS_getAccess() || chr->m_isGmInvisible > INVIS_NONE ) { snprintf((char*)buf,256, "%s is attempting to summon you!", plr->GetName()); SystemMessageToPlr(chr, buf); chr->SummonRequest(plr->GetLowGUID(), plr->GetZoneId(), plr->GetMapId(), plr->GetInstanceID(), plr->GetPosition()); snprintf((char*)buf0,256, "Summon request sent.", chr->GetName()); SystemMessage(m_session, buf0); return true; } snprintf((char*)buf,256, "You are summoning %s.", chr->GetName()); SystemMessage(m_session, buf); if(!(plr->m_isGmInvisible && chr->RS_getAccess() >= RS_SCRIPTER)) { // send message to player snprintf((char*)buf0,256, "You are being summoned by %s.", m_session->GetPlayer()->GetName()); SystemMessageToPlr(chr, buf0); } if(chr->GetTaxiState()) { sEventMgr.RemoveEvents(chr, EVENT_PLAYER_TAXI_DISMOUNT); sEventMgr.RemoveEvents(chr, EVENT_PLAYER_TAXI_INTERPOLATE); chr->SetTaxiState(false); chr->SetTaxiPath(NULL); chr->UnSetTaxiPos(); chr->m_taxi_ride_time = 0; chr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID , 0); chr->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNTED_TAXI); chr->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOCK_PLAYER); chr->SetPlayerSpeed(RUN, chr->m_runSpeed); } if(chr->m_TransporterGUID) { Transporter * pTrans = objmgr.GetTransporter(GUID_LOPART(chr->m_TransporterGUID)); if(pTrans) { if(chr->m_lockTransportVariables == true) { char buff[256]; snprintf((char*)buf,256, "%s is already being teleported.", chr->GetName()); SystemMessage(m_session, buff); return true; } pTrans->RemovePlayer(chr); chr->m_CurrentTransporter = NULL; chr->m_TransporterGUID = 0; } } if( plr->GetMapMgr() == chr->GetMapMgr() ) { chr->_Relocate(plr->GetMapId(),plr->GetPosition(),false,false,plr->GetInstanceID()); } else { sEventMgr.AddEvent(chr,&Player::EventPortToGM,plr,0,1,1,0); } } else { PlayerInfo * pinfo = objmgr.GetPlayerInfoByName(args); if(!pinfo) { char buf[256]; snprintf((char*)buf,256,"Player (%s) does not exist.", args); SystemMessage(m_session, buf); } else { Player * pPlayer = m_session->GetPlayer(); char query[512]; snprintf((char*) &query,512, "UPDATE characters SET mapId = %u, positionX = %f, positionY = %f, positionZ = %f, zoneId = %u WHERE guid = %u;", pPlayer->GetMapId(), pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), pPlayer->GetZoneId(), pinfo->guid); CharacterDatabase.Execute(query); char buf[256]; snprintf((char*)buf,256,"(Offline) %s has been summoned.", pinfo->name); SystemMessage(m_session, buf); } } return true; }
SendStatus TransporterRegistry::prepareSend(const SignalHeader * const signalHeader, Uint8 prio, const Uint32 * const signalData, NodeId nodeId, class SectionSegmentPool & thePool, const SegmentedSectionPtr ptr[3]){ Transporter *t = theTransporters[nodeId]; if(t != NULL && (((ioStates[nodeId] != HaltOutput) && (ioStates[nodeId] != HaltIO)) || ((signalHeader->theReceiversBlockNumber == 252)|| (signalHeader->theReceiversBlockNumber == 4002)))) { if(t->isConnected()){ Uint32 lenBytes = t->m_packer.getMessageLength(signalHeader, ptr); if(lenBytes <= MAX_MESSAGE_SIZE){ Uint32 * insertPtr = t->getWritePtr(lenBytes, prio); if(insertPtr != 0){ t->m_packer.pack(insertPtr, prio, signalHeader, signalData, thePool, ptr); t->updateWritePtr(lenBytes, prio); return SEND_OK; } /** * @note: on linux/i386 the granularity is 10ms * so sleepTime = 2 generates a 10 ms sleep. */ int sleepTime = 2; for(int i = 0; i<50; i++){ if((nSHMTransporters+nSCITransporters) == 0) NdbSleep_MilliSleep(sleepTime); insertPtr = t->getWritePtr(lenBytes, prio); if(insertPtr != 0){ t->m_packer.pack(insertPtr, prio, signalHeader, signalData, thePool, ptr); t->updateWritePtr(lenBytes, prio); break; } } if(insertPtr != 0){ /** * Send buffer full, but resend works */ reportError(callbackObj, nodeId, TE_SEND_BUFFER_FULL); return SEND_OK; } WARNING("Signal to " << nodeId << " lost(buffer)"); reportError(callbackObj, nodeId, TE_SIGNAL_LOST_SEND_BUFFER_FULL); return SEND_BUFFER_FULL; } else { return SEND_MESSAGE_TOO_BIG; } } else { DEBUG("Signal to " << nodeId << " lost(disconnect) "); return SEND_DISCONNECTED; } } else { DEBUG("Discarding message to block: " << signalHeader->theReceiversBlockNumber << " node: " << nodeId); if(t == NULL) return SEND_UNKNOWN_NODE; return SEND_BLOCKED; } }
void game_loop(void) { //load font ALLEGRO_FONT *font = al_load_ttf_font("RobotoMono-Medium.ttf",10,0); //create floor array (will eventually make this a function) srand(time(NULL)); for (int x = 0; x < 16; x++) { //for each y value between 2 and 13 for (int y = 0; y < 16; y++) { randX = 6 + (rand() % (int)(12 - 6 + 1)); randY = 0 + (rand() % (int)(3 - 0 + 1)); //drawDungeonTile(randX, randY, x, y); floorArray [x] [y] [0] = randX; floorArray [x] [y] [1] = randY; } } Player p1; //(speed, friction, sprint accel, max speed) //default: p1.setMovement(1.4, .4, 1.8, 4); p1.setMovement(1.4, .4, 1.8, 3); p1.setPosition(tileSize * 7, tileSize * 12); p1.setCurrentRoom(111); p1.setInitial(tileSize,tileSize,240,240); p1.setH(tileSize); p1.setW(tileSize); p1.setAnimation(tileSize * 0, tileSize * 0,0,0,9,4,0); p1.canMove = true; p1.vincible = true; p1.blinking = false; p1.blinkTimer = 5; p1.setMaxHP(100); p1.setCurrentHP(100); int tempBlinkTimer = p1.blinkTimer; p1.knockback = 0; p1.knockbackTimer = 0; p1.setBound(19,27,7,3, 14,8,9,24); p1.canRotate = true; //p1.setX(240); //p1.setY(240); p1.leavingTransport = 0; //init player prototypes void movePlayerUp(Player &p); void movePlayerDown(Player &p); void movePlayerLeft(Player &p); void movePlayerRight(Player &p); void sprintPlayer(Player &p); void maxSpeedPlayer(Player &p); void maxWalkSpeedPlayer(Player &p); void updatePlayer(Player &p); void collidePlayerWallX(Player &p, int obstacles [16][16]); void collidePlayerWallY(Player &p, int obstacles [16][16]); void collidePlayerMonster(Player &p, Monster m[]); void drawPlayer(Player &p); void resetPlayerAnimation(Player &p); //load current room map Room currentRoom; currentRoom.getWalkRoom(p1.getCurrentRoom()); //currentRoom.getCollideRoom(p1.getCurrentRoom()); //load all objects objectArray currentArray; currentArray.getObjects(p1.getCurrentRoom()); //load current room transporters Transporter currentTrans; currentTrans.exitNumber = 0; //init monsters prototypes Monster currentMonsters[numMonsters]; //load current room's monsters getMonsters(currentMonsters, currentArray.array); void getMonsters (Monster m[], int array[][16]); void drawMonsters (Monster m[]); void collideMonsterWallX(Monster m[], int obstacles [16][16]); void collideMonsterWallY(Monster m[], int obstacles [16][16]); void updateMonstersX (Monster currentMonsters[]); void updateMonstersY (Monster currentMonsters[]); //void seekMonsters (Monster m[], Player p); void seekMonsters (Monster &m, float x, float y); void seekPathMonsters (Monster &m, Player p); void pathfindMonsters (Monster &m, Player p, int obstacles [16][16], int mt); void newPathfindMonster (Monster &m, Player p, int obstacles [16][16]); int monsterDebug = 1; Weapon stick(15, 32, 4, 0, 20, bash, none); stick.setAnimation(tileSize * 0, tileSize * 0,0,0,2,3,0); void updateWeapon(Player &p, Weapon &w); void collideWeaponMonster(Weapon w, Monster m[], Player p); void resetAttack (Player p, Weapon &w); void attackWeapon(Player p, Weapon &w); void drawWeapon(Player p, Weapon &w); void drawCutscene(int num, int message); void closingSplash(void); Cutscene currentCutscene; currentCutscene.cutsceneFont = al_load_ttf_font("data/slkscr.ttf",32,0); int vincibleTimer = 0; int pathCounter = 0; bool showHitboxes = false; bool createCutscene = false; bool inCutscene = false; bool runSeekPath = false; al_start_timer(timer); while (!done) { ALLEGRO_EVENT event; al_wait_for_event(event_queue, &event); if (event.type == ALLEGRO_EVENT_TIMER) { if(key[keyW]) { movePlayerUp(p1); } else if(key[keyS]) { movePlayerDown(p1); } if(key[keyA]) { movePlayerLeft(p1); } else if(key[keyD]) { movePlayerRight(p1); } if(!(key[keyW] || key[keyA] ||key[keyS] ||key[keyD])) { resetPlayerAnimation(p1); } if(key[keyShift] && (key[keyW] || key[keyA] ||key[keyS] ||key[keyD])) { sprintPlayer(p1); } else { maxWalkSpeedPlayer(p1); } maxSpeedPlayer(p1); if(key[keySpace]) { //printf("ATTACK!\n"); } if (runSeekPath) { //seekPathMonsters(currentMonsters[1],p1); //pathfindMonsters( } else { currentMonsters[1].setDx(0); currentMonsters[1].setDy(0); } //update player position p1.setX(p1.getX() + p1.getDx()); collidePlayerMonster(p1,currentMonsters); //printf("player DX: %f\n",p1.getDx()); //printf("player DY: %f\n",p1.getDy()); //X axis //detect and respond to collision with obstacles collidePlayerWallX(p1,currentRoom.collideArray); if(p1.canMove) { p1.setDx(p1.getDx() * p1.getFriction()); } //knockback timer //Y axis p1.setY(p1.getY() + p1.getDy()); collidePlayerWallY(p1,currentRoom.collideArray); p1.setDy(p1.getDy() * p1.getFriction()); //Monster movement and wall collisions for (int i = 0; i < numMonsters; i++) { if (currentMonsters[i].isLive) { newPathfindMonster( currentMonsters[i], p1, currentRoom.collideArray); } } //seekMonsters(currentMonsters[1],p1.getX(), p1.getY()); for (int i = 0; i < numMonsters; i++) { if (currentMonsters[i].isLive) { //seekPathMonsters(currentMonsters[i],p1); seekMonsters(currentMonsters[i],currentMonsters[i].destX, currentMonsters[i].destY); } } //weapon updating updateWeapon(p1,stick); collideWeaponMonster(stick, currentMonsters, p1); updateMonstersX(currentMonsters); collideMonsterWallX(currentMonsters,currentRoom.collideArray); updateMonstersY(currentMonsters); collideMonsterWallY(currentMonsters,currentRoom.collideArray); //if able to transport if (p1.leavingTransport == 0) { //check for collisions with transporter currentTrans.exitNumber = currentTrans.playerTransCollision(p1.getX(), p1.getY(),currentArray.array); if (currentTrans.exitNumber) { currentTrans.fromNumber = p1.getCurrentRoom(); p1.leavingTransport = 1; } } //if transporting if ( p1.leavingTransport == 1) { //set room to move to p1.setCurrentRoom(currentTrans.exitNumber); currentRoom.getWalkRoom(p1.getCurrentRoom()); //currentRoom.getCollideRoom(p1.getCurrentRoom()); currentArray.getObjects(p1.getCurrentRoom()); getMonsters(currentMonsters, currentArray.array); //must set player's location to the location of the exit portal in the new room currentTrans.getDestination(currentArray.array); p1.setX(currentTrans.destination[0] + tileSize/2); p1.setY(currentTrans.destination[1] + tileSize/2); currentTrans.destination[0] = 0; currentTrans.destination[1] = 0; p1.leavingTransport = 0; } //functions for drawing the player (will need to go elsewhere eventually) //invincible timer if (p1.vincible == false) { vincibleTimer ++; tempBlinkTimer --; p1.blinking = true; //printf("p1 blinking? %d, %d\n",p1.blinking, tempBlinkTimer); if (tempBlinkTimer < 0) { p1.blinking = false; if ( tempBlinkTimer == p1.blinkTimer * (-3)) { tempBlinkTimer = p1.blinkTimer; } } if (vincibleTimer == invincibleTime) { p1.vincible = true; p1.blinking = false; vincibleTimer = 0; //printf ("vincible Again \n"); } } pathCounter ++; if (pathCounter == 90) {pathCounter = 0;} redraw = true; } //key pressed down else if (event.type == ALLEGRO_EVENT_KEY_DOWN) { switch (event.keyboard.keycode) { case ALLEGRO_KEY_ESCAPE: done = true; case ALLEGRO_KEY_W: key[keyW] = true; break; case ALLEGRO_KEY_A: key[keyA] = true; break; case ALLEGRO_KEY_S: key[keyS] = true; break; case ALLEGRO_KEY_D: key[keyD] = true; break; case ALLEGRO_KEY_C: key[keyC] = true; if (!inCutscene) { currentCutscene.openDialog ("data/cutscenes/1"); createCutscene = 1; } if (inCutscene) { currentCutscene.currentMessage ++; } while(1) break; case ALLEGRO_KEY_LSHIFT: key[keyShift] = true; break; case ALLEGRO_KEY_SPACE: key[keySpace] = true; runSeekPath = true; //pathfindMonsters( currentMonsters[1], p1, currentRoom.collideArray, pathCounter); newPathfindMonster( currentMonsters[1], p1, currentRoom.collideArray); attackWeapon(p1,stick); break; } } //key released else if (event.type == ALLEGRO_EVENT_KEY_UP) { switch (event.keyboard.keycode) { case ALLEGRO_KEY_W: key[keyW] = false; break; case ALLEGRO_KEY_A: key[keyA] = false; break; case ALLEGRO_KEY_S: key[keyS] = false; break; case ALLEGRO_KEY_D: key[keyD] = false; break; case ALLEGRO_KEY_C: key[keyC] = false; break; case ALLEGRO_KEY_LSHIFT: key[keyShift] = false; break; case ALLEGRO_KEY_SPACE: key[keySpace] = false; resetAttack(p1, stick); break; } } else if(event.type == ALLEGRO_EVENT_MOUSE_AXES || ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY) { crosshair_x = event.mouse.x - crosshairSize/2; crosshair_y = event.mouse.y - crosshairSize/2; } if (redraw && al_is_event_queue_empty(event_queue)) { redraw = false; //Clear screen to black al_clear_to_color(al_map_rgb(0, 0, 0)); if (createCutscene == true) { al_set_target_bitmap(cutsceneBackdrop); al_clear_to_color(al_map_rgb(0, 0, 0)); } //update_graphics(); //graphics that will always be there if (!inCutscene) { drawDungeon(floorArray,currentRoom.walkArray); drawDungeon(floorArray,currentRoom.collideArray); for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { al_draw_textf(font, al_map_rgb(255,255,255),j*tileSize,i*tileSize,ALLEGRO_ALIGN_LEFT,"%d,%d",j+1,i+1); } } if (transDebug) currentTrans.drawTransporters(currentArray.array); drawMonsters(currentMonsters); if (p1.getDir() != UP && p1.getDir() != LEFT) { if (p1.blinking == false) { drawPlayer(p1); } } drawWeapon(p1,stick); if (p1.getDir() == UP || p1.getDir() == LEFT) { if (p1.blinking == false) { drawPlayer(p1); } } al_draw_textf(font, al_map_rgb(255,255,255),0,tileSize*0,ALLEGRO_ALIGN_LEFT,"playerHP: %d",p1.getCurrentHP()); for (int i = 1; i < numMonsters; i++) { if (currentMonsters[i].getCurrentHP() > -10000 && currentMonsters[i].getCurrentHP() <10000) { al_draw_textf(font, al_map_rgb(255,255,255),tileSize * 4 * i,tileSize*15,ALLEGRO_ALIGN_LEFT,"monster %d HP: %d",i,currentMonsters[i].getCurrentHP()); } } } if (inCutscene) { currentCutscene.drawCutscene(1, 1); } //al_draw_bitmap(crosshair, crosshair_x, crosshair_y, 0); if (createCutscene == true) { inCutscene = true; createCutscene = false; al_set_target_bitmap(al_get_backbuffer(display)); //al_lock_bitmap(cutsceneBackdrop); inCutscene = true; } al_flip_display(); } } }
void WorldSession::FullLogin(Player* plr) { DEBUG_LOG("WorldSession", "Fully loading player %u", plr->GetLowGUID()); SetPlayer(plr); m_MoverWoWGuid.Init(plr->GetGUID()); // copy to movement array plr->movement_packet[0] = m_MoverWoWGuid.GetNewGuidMask(); memcpy(&plr->movement_packet[1], m_MoverWoWGuid.GetNewGuid(), m_MoverWoWGuid.GetNewGuidLen()); /* world preload */ packetSMSG_LOGIN_VERIFY_WORLD vwpck; vwpck.MapId = plr->GetMapId(); vwpck.O = plr->GetOrientation(); vwpck.X = plr->GetPositionX(); vwpck.Y = plr->GetPositionY(); vwpck.Z = plr->GetPositionZ(); OutPacket( SMSG_LOGIN_VERIFY_WORLD, sizeof(packetSMSG_LOGIN_VERIFY_WORLD), &vwpck ); // send voicechat state - active/inactive /* {SERVER} Packet: (0x03C7) UNKNOWN PacketSize = 2 |------------------------------------------------|----------------| |00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF| |------------------------------------------------|----------------| |02 01 |.. | ------------------------------------------------------------------- */ WorldPacket datab; datab.Initialize(SMSG_FEATURE_SYSTEM_STATUS); datab << uint8(2) << uint8(0); SendPacket(&datab); datab.Initialize(SMSG_LEARNED_DANCE_MOVES); datab << uint32(0); datab << uint32(0); SendPacket(&datab); plr->UpdateAttackSpeed(); // Anti max level hack. if(sWorld.LevelCap_Custom_All && (plr->getLevel() > sWorld.LevelCap_Custom_All)) plr->SetUInt32Value(UNIT_FIELD_LEVEL, sWorld.LevelCap_Custom_All); // Enable certain GM abilities on login. if(HasGMPermissions()) { plr->bGMTagOn = true; plr->m_isGmInvisible = true; plr->m_invisible = true; if(CanUseCommand('z')) { plr->SetFlag(PLAYER_FLAGS, PLAYER_FLAG_DEVELOPER); plr->triggerpass_cheat = true; // Enable for admins automatically. } else plr->SetFlag(PLAYER_FLAGS, PLAYER_FLAG_GM); } // Make sure our name exists (for premade system) PlayerInfo * info = objmgr.GetPlayerInfo(plr->GetLowGUID()); if(info == NULL) { info = new PlayerInfo; memset(info, 0, sizeof(PlayerInfo)); info->cl = plr->getClass(); info->gender = plr->getGender(); info->guid = plr->GetLowGUID(); info->name = strdup(plr->GetName()); info->lastLevel = plr->getLevel(); info->lastOnline = UNIXTIME; info->lastZone = plr->GetZoneId(); info->race = plr->getRace(); info->team = plr->GetTeam(); objmgr.AddPlayerInfo(info); } plr->m_playerInfo = info; if(plr->m_playerInfo->guild) { plr->m_uint32Values[PLAYER_GUILDID] = plr->m_playerInfo->guild->GetGuildId(); plr->m_uint32Values[PLAYER_GUILDRANK] = plr->m_playerInfo->guildRank->iId; } for(uint32 z = 0; z < NUM_ARENA_TEAM_TYPES; ++z) { if(plr->m_playerInfo->arenaTeam[z] != NULL) { plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (z*6), plr->m_playerInfo->arenaTeam[z]->m_id); if(plr->m_playerInfo->arenaTeam[z]->m_leader == plr->GetLowGUID()) plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (z*6) + 1, 0); else plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (z*6) + 1, 1); } } info->m_loggedInPlayer = plr; // account data == UI config if(sWorld.m_useAccountData) { WorldPacket data(SMSG_ACCOUNT_DATA_TIMES, 4+1+4+8*4); MD5Hash md5hash; data << uint32(UNIXTIME) << uint8(1) << uint32(0xEA); for (int i = 0; i < 8; i++) { AccountDataEntry* acct_data = GetAccountData(i); if(0xEA & (1 << i)) data << uint32(acct_data->Time); md5hash.Initialize(); md5hash.UpdateData((const uint8*)acct_data->data, acct_data->sz); md5hash.Finalize(); } SendPacket(&data); } else { WorldPacket data(SMSG_ACCOUNT_DATA_TIMES, 4+1+4+8*4); MD5Hash md5hash; data << uint32(UNIXTIME) << uint8(1) << uint32(0xEA); for (int i = 0; i < 8; i++) { if(0xEA & (1 << i)) data << uint32(0); AccountDataEntry* acct_data = GetAccountData(i); if(acct_data) { md5hash.Initialize(); md5hash.UpdateData((const uint8*)acct_data->data, acct_data->sz); md5hash.Finalize(); } } SendPacket(&data); } // Set TIME OF LOGIN CharacterDatabase.Execute ("UPDATE characters SET online = 1 WHERE guid = %u" , plr->GetLowGUID()); bool enter_world = true; #ifndef CLUSTERING // Find our transporter and add us if we're on one. if(plr->m_TransporterGUID != 0) { Transporter* pTrans = objmgr.GetTransporter(GUID_LOPART(plr->m_TransporterGUID)); if(pTrans) { if(plr->isDead()) { plr->RemoteRevive(); } float c_tposx = pTrans->GetPositionX() + plr->m_transportPosition->x; float c_tposy = pTrans->GetPositionY() + plr->m_transportPosition->y; float c_tposz = pTrans->GetPositionZ() + plr->m_transportPosition->z; if(plr->GetMapId() != pTrans->GetMapId()) // loaded wrong map { plr->SetMapId(pTrans->GetMapId()); WorldPacket dataw(SMSG_NEW_WORLD, 20); dataw << pTrans->GetMapId() << c_tposx << c_tposy << c_tposz << plr->GetOrientation(); SendPacket(&dataw); // shit is sent in worldport ack. enter_world = false; } plr->SetPosition(c_tposx, c_tposy, c_tposz, plr->GetOrientation(), false); plr->m_CurrentTransporter = pTrans; pTrans->AddPlayer(plr); } } #endif if(plr->GetVehicle()) plr->GetVehicle()->RemovePassenger(plr); DEBUG_LOG( "WorldSession","Player %s logged in.", plr->GetName()); if(plr->GetTeam() == 1) sWorld.HordePlayers++; else sWorld.AlliancePlayers++; if(sWorld.SendMovieOnJoin && plr->m_FirstLogin && !HasGMPermissions()) plr->SendCinematic(plr->myRace->cinematic_id); DEBUG_LOG( "WorldSession","Created new player for existing players (%s)", plr->GetName() ); // Login time, will be used for played time calc plr->m_playedtime[2] = (uint32)UNIXTIME; //Issue a message telling all guild members that this player has signed on if(plr->IsInGuild()) { Guild *pGuild = plr->m_playerInfo->guild; if(pGuild) { WorldPacket data(SMSG_GUILD_EVENT, 50); data << uint8(GUILD_EVENT_MOTD); data << uint8(0x01); if(pGuild->GetMOTD()) data << pGuild->GetMOTD(); else data << uint8(0); SendPacket(&data); pGuild->LogGuildEvent(GUILD_EVENT_HASCOMEONLINE, 1, plr->GetName()); } } // Send online status to people having this char in friendlist (excluding GM's) if(!HasGMPermissions()) plr->Social_TellFriendsOnline(); // send friend list (for ignores) plr->Social_SendFriendList(7); // Send revision plr->BroadcastMessage("%sServer:|r%s Sandshroud Hearthstone|r %s r%u-%s-%s", MSG_COLOR_GOLD, MSG_COLOR_ORANGEY, MSG_COLOR_TORQUISEBLUE, BUILD_REVISION, ARCH, CONFIG); plr->BroadcastMessage("%sPlease report all bugs to |r%shttp://mantis.sandshroud.org|r", MSG_COLOR_GOLD, MSG_COLOR_TORQUISEBLUE); plr->BroadcastMessage("%sOnline Players:|r%s %u |r%sPeak:|r%s %u |r%sAccepted Connections:|r%s %u |r", MSG_COLOR_GOLD, MSG_COLOR_TORQUISEBLUE, sWorld.GetSessionCount(), MSG_COLOR_GOLD, MSG_COLOR_TORQUISEBLUE, sWorld.PeakSessionCount, MSG_COLOR_GOLD, MSG_COLOR_TORQUISEBLUE, sWorld.mAcceptedConnections); plr->BroadcastMessage("%sServer Uptime:|r%s %s|r", MSG_COLOR_GOLD, MSG_COLOR_TORQUISEBLUE, sWorld.GetUptimeString().c_str()); // send to gms if(HasGMPermissions()) sWorld.SendMessageToGMs(this, "%s%s %s (%s) is now online.|r", MSG_COLOR_GOLD, CanUseCommand('z') ? "Admin" : "GameMaster", plr->GetName(), GetAccountNameS(), GetPermissions()); // Send first line of MOTD WorldPacket datat(SMSG_MOTD, 10); datat << uint32(0x04); datat << sWorld.GetMotd(); SendPacket(&datat); // Send second line of MOTD WorldPacket datat2(SMSG_MOTD, 10); datat2 << uint32(0x04); datat2 << sWorld.GetMotd2(); SendPacket(&datat2); //Set current RestState if( plr->m_isResting) // We are in a resting zone, turn on Zzz plr->ApplyPlayerRestState(true); //Check if there is a time difference between lastlogoff and now if( plr->m_timeLogoff > 0 && plr->GetUInt32Value(UNIT_FIELD_LEVEL) < plr->GetUInt32Value(PLAYER_FIELD_MAX_LEVEL)) // if timelogoff = 0 then it's the first login { uint32 currenttime = (uint32)UNIXTIME; uint32 timediff = currenttime - plr->m_timeLogoff; //Calculate rest bonus if( timediff > 0 ) plr->AddCalculatedRestXP(timediff); } sHookInterface.OnFullLogin(plr); if(info->m_Group) info->m_Group->Update(); if(!sWorld.m_blockgmachievements || !HasGMPermissions()) { // Retroactive: Level achievement plr->GetAchievementInterface()->HandleAchievementCriteriaLevelUp( plr->getLevel() ); // Send achievement data! if( plr->GetAchievementInterface()->HasAchievements() ) { WorldPacket * data = plr->GetAchievementInterface()->BuildAchievementData(); plr->CopyAndSendDelayedPacket(data); delete data; } } if(enter_world && !plr->GetMapMgr()) plr->AddToWorld(true); sTracker.CheckPlayerForTracker(plr, true); // If we have the talent, it returns anyway, so just call the function. plr->ResetTitansGrip(); if(plr->GetItemInterface()) plr->GetItemInterface()->CheckAreaItems(); objmgr.AddPlayer(plr); }
void WorldSession::FullLogin(Player* plr) { DEBUG_LOG("WorldSession", "Fully loading player %u", plr->GetLowGUID()); SetPlayer(plr); m_MoverWoWGuid.Init(plr->GetGUID()); // copy to movement array //movement_packet[0] = m_MoverWoWGuid.GetNewGuidMask(); //memcpy(&movement_packet[1], m_MoverWoWGuid.GetNewGuid(), m_MoverWoWGuid.GetNewGuidLen()); WorldPacket datab(MSG_SET_DUNGEON_DIFFICULTY, 20); datab << plr->iInstanceType; datab << uint32(0x01); datab << uint32(0x00); SendPacket(&datab); WorldPacket datat(SMSG_MOTD, 50); datat << uint32(0x04); datat << sWorld.GetMotd(); SendPacket(&datat); /* world preload */ packetSMSG_LOGIN_VERIFY_WORLD vwpck; vwpck.MapId = plr->GetMapId(); vwpck.O = plr->GetOrientation(); vwpck.X = plr->GetPositionX(); vwpck.Y = plr->GetPositionY(); vwpck.Z = plr->GetPositionZ(); OutPacket( SMSG_LOGIN_VERIFY_WORLD, sizeof(packetSMSG_LOGIN_VERIFY_WORLD), &vwpck ); // send voicechat state - active/inactive /* {SERVER} Packet: (0x03C7) UNKNOWN PacketSize = 2 |------------------------------------------------|----------------| |00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF| |------------------------------------------------|----------------| |02 01 |.. | ------------------------------------------------------------------- */ #ifdef VOICE_CHAT datab.Initialize(SMSG_FEATURE_SYSTEM_STATUS); datab << uint8(2) << uint8(sVoiceChatHandler.CanUseVoiceChat() ? 1 : 0); SendPacket(&datab); #else datab.Initialize(SMSG_FEATURE_SYSTEM_STATUS); datab << uint8(2) << uint8(0); #endif plr->UpdateAttackSpeed(); /*if(plr->getLevel()>70) plr->SetUInt32Value(UNIT_FIELD_LEVEL,70);*/ // Enable trigger cheat by default //plr->triggerpass_cheat = HasGMPermissions(); // Make sure our name exists (for premade system) PlayerInfo * info = objmgr.GetPlayerInfo(plr->GetLowGUID()); if(info == 0) { info = new PlayerInfo; memset(info, 0, sizeof(PlayerInfo)); info->cl = plr->getClass(); info->gender = plr->getGender(); info->guid = plr->GetLowGUID(); info->name = strdup(plr->GetName()); info->lastLevel = plr->getLevel(); info->lastOnline = UNIXTIME; info->lastZone = plr->GetZoneId(); info->race = plr->getRace(); info->team = plr->GetTeam(); objmgr.AddPlayerInfo(info); } plr->m_playerInfo = info; if(plr->m_playerInfo->guild) { plr->m_uint32Values[PLAYER_GUILDID] = plr->m_playerInfo->guild->GetGuildId(); plr->m_uint32Values[PLAYER_GUILDRANK] = plr->m_playerInfo->guildRank->iId; } for(uint32 z = 0; z < NUM_ARENA_TEAM_TYPES; ++z) { if(_player->m_playerInfo->arenaTeam[z] != NULL) { _player->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (z*7), _player->m_playerInfo->arenaTeam[z]->m_id); if(_player->m_playerInfo->arenaTeam[z]->m_leader == _player->GetLowGUID()) _player->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (z*7) + 1, 0); else _player->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (z*7) + 1, 1); } } info->m_loggedInPlayer = plr; // account data == UI config SendAccountDataTimes(PER_CHARACTER_CACHE_MASK); _player->ResetTitansGrip(); // Set TIME OF LOGIN CharacterDatabase.Execute ( "UPDATE characters SET online = 1 WHERE guid = %u" , plr->GetLowGUID()); bool enter_world = true; #ifndef CLUSTERING // Find our transporter and add us if we're on one. if(plr->m_TransporterGUID != 0) { Transporter* pTrans = objmgr.GetTransporter(GUID_LOPART(plr->m_TransporterGUID)); if(pTrans) { if(plr->isDead()) { plr->RemoteRevive(); } float c_tposx = pTrans->GetPositionX() + plr->m_TransporterX; float c_tposy = pTrans->GetPositionY() + plr->m_TransporterY; float c_tposz = pTrans->GetPositionZ() + plr->m_TransporterZ; if(plr->GetMapId() != pTrans->GetMapId()) // loaded wrong map { plr->SetMapId(pTrans->GetMapId()); WorldPacket dataw(SMSG_NEW_WORLD, 20); dataw << pTrans->GetMapId() << c_tposx << c_tposy << c_tposz << plr->GetOrientation(); SendPacket(&dataw); // shit is sent in worldport ack. enter_world = false; } plr->SetPosition(c_tposx, c_tposy, c_tposz, plr->GetOrientation(), false); plr->m_CurrentTransporter = pTrans; pTrans->AddPlayer(plr); } } #endif DEBUG_LOG( "WorldSession","Player %s logged in.", plr->GetName()); if(plr->GetTeam() == 1) sWorld.HordePlayers++; else sWorld.AlliancePlayers++; if(plr->m_FirstLogin && !HasGMPermissions()) OutPacket(SMSG_TRIGGER_CINEMATIC, 4, &plr->myRace->cinematic_id); DEBUG_LOG( "WorldSession","Created new player for existing players (%s)", plr->GetName() ); // Login time, will be used for played time calc plr->m_playedtime[2] = (uint32)UNIXTIME; //Issue a message telling all guild members that this player has signed on if(plr->IsInGuild()) { Guild *pGuild = plr->m_playerInfo->guild; if(pGuild) { WorldPacket data(50); data.Initialize(SMSG_GUILD_EVENT); data << uint8(GUILD_EVENT_MOTD); data << uint8(0x01); if(pGuild->GetMOTD()) data << pGuild->GetMOTD(); else data << uint8(0); SendPacket(&data); pGuild->LogGuildEvent(GUILD_EVENT_HASCOMEONLINE, 1, plr->GetName()); } } // Send online status to people having this char in friendlist (excluding GM's) if(!HasGMPermissions()) _player->Social_TellFriendsOnline(); // send friend list (for ignores) _player->Social_SendFriendList(7); // Send revision (if enabled) #ifdef WIN32 _player->BroadcastMessage("Server: %sAscent %s r%u/%s-Win-%s %s(www.ascentemulator.net)", MSG_COLOR_WHITE, BUILD_REVISION, CONFIG, ARCH, MSG_COLOR_LIGHTBLUE); #else _player->BroadcastMessage("Server: %sAscent %s r%u/%s-%s %s(www.ascentemulator.net)", MSG_COLOR_WHITE, BUILD_REVISION, PLATFORM_TEXT, ARCH, MSG_COLOR_LIGHTBLUE); #endif if(sWorld.SendStatsOnJoin) { _player->BroadcastMessage("Online Players: %s%u |rPeak: %s%u|r Accepted Connections: %s%u", MSG_COLOR_WHITE, sWorld.GetSessionCount(), MSG_COLOR_WHITE, sWorld.PeakSessionCount, MSG_COLOR_WHITE, sWorld.mAcceptedConnections); _player->BroadcastMessage("Server Uptime: |r%s", sWorld.GetUptimeString().c_str()); } // send to gms if( HasGMPermissions() ) sWorld.SendMessageToGMs(this, "GM %s (%s) is now online. (Permissions: [%s])", _player->GetName(), GetAccountNameS(), GetPermissions()); //Set current RestState if( plr->m_isResting) // We are in a resting zone, turn on Zzz plr->ApplyPlayerRestState(true); //Check if there is a time difference between lastlogoff and now if( plr->m_timeLogoff > 0 && plr->GetUInt32Value(UNIT_FIELD_LEVEL) < plr->GetUInt32Value(PLAYER_FIELD_MAX_LEVEL)) // if timelogoff = 0 then it's the first login { uint32 currenttime = (uint32)UNIXTIME; uint32 timediff = currenttime - plr->m_timeLogoff; //Calculate rest bonus if( timediff > 0 ) plr->AddCalculatedRestXP(timediff); } sHookInterface.OnEnterWorld2(_player); if(info->m_Group) info->m_Group->Update(); // Retroactive: Level achievement _player->GetAchievementInterface()->HandleAchievementCriteriaLevelUp( _player->getLevel() ); // Retroactive: Bank slots: broken atm :( //_player->GetAchievementInterface()->HandleAchievementCriteriaBuyBankSlot(true); // Send achievement data! if( _player->GetAchievementInterface()->HasAchievements() ) { WorldPacket * data = _player->GetAchievementInterface()->BuildAchievementData(); _player->CopyAndSendDelayedPacket(data); delete data; } SendAccountDataTimes(GLOBAL_CACHE_MASK); if(enter_world && !_player->GetMapMgr()) plr->AddToWorld(); objmgr.AddPlayer(_player); }
void WorldSession::FullLogin(Player* plr) { sLog.Debug("WorldSession", "Fully loading player %u", plr->GetLowGUID()); SetPlayer(plr); m_MoverWoWGuid.Init(plr->GetGUID()); /* world preload */ packetSMSG_LOGIN_VERIFY_WORLD vwpck; vwpck.MapId = plr->GetMapId(); vwpck.O = plr->GetOrientation(); vwpck.X = plr->GetPositionX(); vwpck.Y = plr->GetPositionY(); vwpck.Z = plr->GetPositionZ(); OutPacket( SMSG_LOGIN_VERIFY_WORLD, sizeof(packetSMSG_LOGIN_VERIFY_WORLD), &vwpck ); // send voicechat state - active/inactive /* {SERVER} Packet: (0x03C7) UNKNOWN PacketSize = 2 |------------------------------------------------|----------------| |00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF| |------------------------------------------------|----------------| |02 01 |.. | ------------------------------------------------------------------- */ WorldPacket datab(SMSG_FEATURE_SYSTEM_STATUS, 2); datab << uint8(2) << uint8(0); SendPacket(&datab); datab.Initialize(SMSG_LEARNED_DANCE_MOVES, 8); datab << uint32(0); datab << uint32(0); SendPacket(&datab); plr->UpdateStats(); // Anti max level hack. if(sWorld.LevelCap_Custom_All && (plr->getLevel() > sWorld.LevelCap_Custom_All)) plr->SetUInt32Value(UNIT_FIELD_LEVEL, sWorld.LevelCap_Custom_All); // Enable certain GM abilities on login. if(HasGMPermissions()) { plr->bGMTagOn = true; plr->m_isGmInvisible = true; plr->m_invisible = true; plr->bInvincible = true; if(CanUseCommand('z')) { plr->SetFlag(PLAYER_FLAGS, PLAYER_FLAG_DEVELOPER); plr->triggerpass_cheat = true; // Enable for admins automatically. } else plr->SetFlag(PLAYER_FLAGS, PLAYER_FLAG_GM); } // Make sure our name exists (for premade system) PlayerInfo * info = objmgr.GetPlayerInfo(plr->GetLowGUID()); if(info == NULL) { info = new PlayerInfo; memset(info, 0, sizeof(PlayerInfo)); info->_class = plr->getClass(); info->gender = plr->getGender(); info->guid = plr->GetLowGUID(); info->name = strdup(plr->GetName()); info->lastLevel = plr->getLevel(); info->lastOnline = UNIXTIME; info->lastZone = plr->GetZoneId(); info->race = plr->getRace(); info->team = plr->GetTeam(); objmgr.AddPlayerInfo(info); } plr->m_playerInfo = info; if(plr->m_playerInfo->GuildId) { plr->m_uint32Values[PLAYER_GUILDID] = plr->m_playerInfo->GuildId; plr->m_uint32Values[PLAYER_GUILDRANK] = plr->m_playerInfo->GuildRank; } for(uint32 z = 0; z < NUM_ARENA_TEAM_TYPES; ++z) { if(plr->m_playerInfo->arenaTeam[z] != NULL) { plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (z*6), plr->m_playerInfo->arenaTeam[z]->m_id); if(plr->m_playerInfo->arenaTeam[z]->m_leader == plr->GetLowGUID()) plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (z*6) + 1, 0); else plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (z*6) + 1, 1); } } info->m_loggedInPlayer = plr; // account data == UI config if(sWorld.m_useAccountData) { WorldPacket data(SMSG_ACCOUNT_DATA_TIMES, 4+1+4+8*4); MD5Hash md5hash; data << uint32(UNIXTIME) << uint8(1) << uint32(0xEA); for (int i = 0; i < 8; i++) { AccountDataEntry* acct_data = GetAccountData(i); if(0xEA & (1 << i)) data << uint32(acct_data->Time); md5hash.Initialize(); md5hash.UpdateData((const uint8*)acct_data->data, acct_data->sz); md5hash.Finalize(); } SendPacket(&data); } else { WorldPacket data(SMSG_ACCOUNT_DATA_TIMES, 4+1+4+8*4); MD5Hash md5hash; data << uint32(UNIXTIME) << uint8(1) << uint32(0xEA); for (int i = 0; i < 8; i++) { if(0xEA & (1 << i)) data << uint32(0); AccountDataEntry* acct_data = GetAccountData(i); if(acct_data) { md5hash.Initialize(); md5hash.UpdateData((const uint8*)acct_data->data, acct_data->sz); md5hash.Finalize(); } } SendPacket(&data); } // Set TIME OF LOGIN CharacterDatabase.Execute("UPDATE characters SET online = 1 WHERE guid = %u" , plr->GetLowGUID()); bool enter_world = true; // Find our transporter and add us if we're on one. if(plr->GetTransportGuid() != 0) { uint64 transGuid = plr->GetTransportGuid(); Transporter* pTrans = objmgr.GetTransporter(GUID_LOPART(transGuid)); if(pTrans) { if(plr->isDead()) plr->RemoteRevive(); float c_tposx, c_tposy, c_tposz, c_tposo; plr->GetMovementInfo()->GetTransportPosition(c_tposx, c_tposy, c_tposz, c_tposo); c_tposx += pTrans->GetPositionX(); c_tposy += pTrans->GetPositionY(); c_tposz += pTrans->GetPositionZ(); if(plr->GetMapId() != pTrans->GetMapId()) // loaded wrong map { plr->SetMapId(pTrans->GetMapId()); WorldPacket dataw(SMSG_NEW_WORLD, 20); dataw << pTrans->GetMapId() << c_tposx << c_tposy << c_tposz << c_tposo; SendPacket(&dataw); // shit is sent in worldport ack. enter_world = false; } plr->SetPosition(c_tposx, c_tposy, c_tposz, c_tposo); plr->m_CurrentTransporter = pTrans; pTrans->AddPlayer(plr); } } if(plr->GetVehicle()) plr->GetVehicle()->RemovePassenger(plr); sLog.Debug( "WorldSession","Player %s logged in.", plr->GetName()); if(plr->GetTeam() == 1) sWorld.HordePlayers++; else sWorld.AlliancePlayers++; if(sWorld.SendMovieOnJoin && plr->m_FirstLogin && !HasGMPermissions()) plr->SendCinematic(plr->myRace->cinematic_id); sLog.Debug( "WorldSession","Created new player for existing players (%s)", plr->GetName() ); // Login time, will be used for played time calc plr->m_playedtime[2] = (uint32)UNIXTIME; // Send online status to people having this char in friendlist plr->Social_TellOnlineStatus(); // send friend list (for ignores) plr->Social_SendFriendList(7); // send to gms if(HasGMPermissions()) sWorld.SendMessageToGMs(this, "%s%s %s (%s) is now online.|r", MSG_COLOR_GOLD, CanUseCommand('z') ? "Admin" : "GameMaster", plr->GetName(), GetAccountNameS(), GetPermissions()); //Set current RestState if( plr->m_isResting) // We are in a resting zone, turn on Zzz plr->ApplyPlayerRestState(true); //Check if there is a time difference between lastlogoff and now if( plr->m_timeLogoff > 0 && plr->GetUInt32Value(UNIT_FIELD_LEVEL) < plr->GetUInt32Value(PLAYER_FIELD_MAX_LEVEL)) // if timelogoff = 0 then it's the first login { uint32 currenttime = (uint32)UNIXTIME; uint32 timediff = currenttime - plr->m_timeLogoff; //Calculate rest bonus if( timediff > 0 ) plr->AddCalculatedRestXP(timediff); } sHookInterface.OnFullLogin(plr); if(info->m_Group) info->m_Group->Update(); if(!sWorld.m_blockgmachievements || !HasGMPermissions()) { // Retroactive: Level achievement plr->GetAchievementInterface()->HandleAchievementCriteriaLevelUp( plr->getLevel() ); // Send achievement data! if( plr->GetAchievementInterface()->HasAchievements() ) { WorldPacket * data = plr->GetAchievementInterface()->BuildAchievementData(); plr->CopyAndSendDelayedPacket(data); delete data; } } if(enter_world && !plr->GetMapMgr()) plr->AddToWorld(true); sTracker.CheckPlayerForTracker(plr, true); // If we have the talent, it returns anyway, so just call the function. plr->ResetTitansGrip(); if(plr->GetItemInterface()) plr->GetItemInterface()->CheckAreaItems(); objmgr.AddPlayer(plr); }
void WorldSession::FullLogin(Player* plr) { Log.Debug("WorldSession", "Fully loading player %u", plr->GetLowGUID()); SetPlayer(plr); m_MoverWoWGuid.Init(plr->GetGUID()); MapMgr* mgr = sInstanceMgr.GetInstance(plr); if(mgr && mgr->m_battleground) { // Don't allow player to login into a bg that has ended or is full if(mgr->m_battleground->HasEnded() == true || mgr->m_battleground->HasFreeSlots(plr->GetTeamInitial(), mgr->m_battleground->GetType() == false)) { mgr = NULL; } } // Trying to log to an instance that doesn't exists anymore? if(!mgr) { if(!IS_INSTANCE(plr->m_bgEntryPointMap)) { plr->m_position.x = plr->m_bgEntryPointX; plr->m_position.y = plr->m_bgEntryPointY; plr->m_position.z = plr->m_bgEntryPointZ; plr->m_position.o = plr->m_bgEntryPointO; plr->m_mapId = plr->m_bgEntryPointMap; } else { plr->m_position.x = plr->GetBindPositionX(); plr->m_position.y = plr->GetBindPositionY(); plr->m_position.z = plr->GetBindPositionZ(); plr->m_position.o = 0; plr->m_mapId = plr->GetBindMapId(); } } // copy to movement array movement_packet[0] = m_MoverWoWGuid.GetNewGuidMask(); memcpy(&movement_packet[1], m_MoverWoWGuid.GetNewGuid(), m_MoverWoWGuid.GetNewGuidLen()); // world preload uint32 VMapId; float VO; float VX; float VY; float VZ; // GMs should start on GM Island and be bound there if(HasGMPermissions() && plr->m_FirstLogin && sWorld.gamemaster_startonGMIsland) { VMapId = 1; VO = 0; VX = 16222.6f; VY = 16265.9f; VZ = 14.2085f; plr->m_position.x = VX; plr->m_position.y = VY; plr->m_position.z = VZ; plr->m_position.o = VO; plr->m_mapId = VMapId; plr->SetBindPoint(plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetMapId(), plr->GetZoneId()); } else { VMapId = plr->GetMapId(); VO = plr->GetOrientation(); VX = plr->GetPositionX(); VY = plr->GetPositionY(); VZ = plr->GetPositionZ(); } plr->SendLoginVerifyWorld(VMapId, VX, VY, VZ, VO); /////////////////////////////////////////////////////////////////////////////////////////////////////// // send voicechat state - active/inactive // // {SERVER} Packet: (0x03C7) UNKNOWN PacketSize = 2 // |------------------------------------------------|----------------| // |00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF| // |------------------------------------------------|----------------| // |02 01 |.. | // ------------------------------------------------------------------- // // // Old packetdump is OLD. This is probably from 2.2.0 (that was the patch when it was added to wow)! // ////////////////////////////////////////////////////////////////////////////////////////////////////// StackWorldPacket<20> datab(SMSG_FEATURE_SYSTEM_STATUS); datab.Initialize(SMSG_FEATURE_SYSTEM_STATUS); datab << uint8(2); datab << uint8(0); SendPacket(&datab); WorldPacket dataldm(SMSG_LEARNED_DANCE_MOVES, 4 + 4); dataldm << uint32(0); dataldm << uint32(0); SendPacket(&dataldm); plr->UpdateAttackSpeed(); // Make sure our name exists (for premade system) PlayerInfo* info = objmgr.GetPlayerInfo(plr->GetLowGUID()); if(info == NULL) { info = new PlayerInfo; info->cl = plr->getClass(); info->gender = plr->getGender(); info->guid = plr->GetLowGUID(); info->name = strdup(plr->GetName()); info->lastLevel = plr->getLevel(); info->lastOnline = UNIXTIME; info->lastZone = plr->GetZoneId(); info->race = plr->getRace(); info->team = plr->GetTeam(); info->guild = NULL; info->guildRank = NULL; info->guildMember = NULL; info->m_Group = NULL; info->subGroup = 0; objmgr.AddPlayerInfo(info); } plr->m_playerInfo = info; if(plr->m_playerInfo->guild) { plr->SetGuildId(plr->m_playerInfo->guild->GetGuildId()); plr->SetGuildRank(plr->m_playerInfo->guildRank->iId); } info->m_loggedInPlayer = plr; // account data == UI config SendAccountDataTimes(PER_CHARACTER_CACHE_MASK); // Set TIME OF LOGIN CharacterDatabase.Execute("UPDATE characters SET online = 1 WHERE guid = %u" , plr->GetLowGUID()); bool enter_world = true; // Find our transporter and add us if we're on one. if(plr->transporter_info.guid != 0) { Transporter* pTrans = objmgr.GetTransporter(Arcemu::Util::GUID_LOPART(plr->transporter_info.guid)); if(pTrans) { if(plr->IsDead()) { plr->ResurrectPlayer(); plr->SetHealth(plr->GetMaxHealth()); plr->SetPower(POWER_TYPE_MANA, plr->GetMaxPower(POWER_TYPE_MANA)); } float c_tposx = pTrans->GetPositionX() + plr->transporter_info.x; float c_tposy = pTrans->GetPositionY() + plr->transporter_info.y; float c_tposz = pTrans->GetPositionZ() + plr->transporter_info.z; if(plr->GetMapId() != pTrans->GetMapId()) // loaded wrong map { plr->SetMapId(pTrans->GetMapId()); StackWorldPacket<20> dataw(SMSG_NEW_WORLD); dataw << pTrans->GetMapId(); dataw << c_tposx; dataw << c_tposy; dataw << c_tposz; dataw << plr->GetOrientation(); SendPacket(&dataw); // shit is sent in worldport ack. enter_world = false; } plr->SetPosition(c_tposx, c_tposy, c_tposz, plr->GetOrientation(), false); plr->m_CurrentTransporter = pTrans; pTrans->AddPlayer(plr); } } Log.Debug("Login", "Player %s logged in.", plr->GetName()); sWorld.incrementPlayerCount(plr->GetTeam()); if(plr->m_FirstLogin) { uint32 introid = plr->info->introid; OutPacket(SMSG_TRIGGER_CINEMATIC, 4, &introid); if(sWorld.m_AdditionalFun) //cebernic: tells people who 's newbie :D { const int classtext[] = {0, 5, 6, 8, 9, 11, 0, 4, 3, 7, 0, 10}; sWorld.SendLocalizedWorldText(true, "{65}", classtext[(uint32)plr->getClass() ] , plr->GetName() , (plr->IsTeamHorde() ? "{63}" : "{64}")); } } LOG_DETAIL("WORLD: Created new player for existing players (%s)", plr->GetName()); // Login time, will be used for played time calc plr->m_playedtime[2] = uint32(UNIXTIME); //Issue a message telling all guild members that this player has signed on if(plr->IsInGuild()) { Guild* pGuild = plr->m_playerInfo->guild; if(pGuild) { WorldPacket data(SMSG_GUILD_EVENT, 50); data << uint8(GUILD_EVENT_MOTD); data << uint8(1); if(pGuild->GetMOTD()) data << pGuild->GetMOTD(); else data << uint8(0); SendPacket(&data); pGuild->LogGuildEvent(GUILD_EVENT_HASCOMEONLINE, 1, plr->GetName()); } } // Send online status to people having this char in friendlist _player->Social_TellFriendsOnline(); // send friend list (for ignores) _player->Social_SendFriendList(7); plr->SendDungeonDifficulty(); plr->SendRaidDifficulty(); plr->SendEquipmentSetList(); #ifndef GM_TICKET_MY_MASTER_COMPATIBLE GM_Ticket* ticket = objmgr.GetGMTicketByPlayer(_player->GetGUID()); if(ticket != NULL) { //Send status change to gm_sync_channel Channel* chn = channelmgr.GetChannel(sWorld.getGmClientChannel().c_str(), _player); if(chn) { std::stringstream ss; ss << "GmTicket:" << GM_TICKET_CHAT_OPCODE_ONLINESTATE; ss << ":" << ticket->guid; ss << ":1"; chn->Say(_player, ss.str().c_str(), NULL, true); } } #endif #ifdef WIN32 _player->BroadcastMessage("Server: %sArcEmu %s - %s-Windows-%s", MSG_COLOR_WHITE, BUILD_TAG, CONFIG, ARCH); #else _player->BroadcastMessage("Server: %sArcEmu %s - %s-%s", MSG_COLOR_WHITE, BUILD_TAG, PLATFORM_TEXT, ARCH); #endif // Revision _player->BroadcastMessage("Build hash: %s%s", MSG_COLOR_CYAN, BUILD_HASH_STR); // Bugs _player->BroadcastMessage("Bugs: %s%s", MSG_COLOR_SEXHOTPINK, BUGTRACKER); // Recruiting message _player->BroadcastMessage(RECRUITING); // Shows Online players, and connection peak _player->BroadcastMessage("Online Players: %s%u |rPeak: %s%u|r Accepted Connections: %s%u", MSG_COLOR_SEXGREEN, sWorld.GetSessionCount(), MSG_COLOR_SEXBLUE, sWorld.PeakSessionCount, MSG_COLOR_SEXBLUE, sWorld.mAcceptedConnections); // Shows Server uptime _player->BroadcastMessage("Server Uptime: |r%s", sWorld.GetUptimeString().c_str()); // server Message Of The Day SendMOTD(); //Set current RestState if(plr->m_isResting) // We are resting at an inn , turn on Zzz plr->ApplyPlayerRestState(true); //Calculate rest bonus if there is time between lastlogoff and now if(plr->m_timeLogoff > 0 && plr->getLevel() < plr->GetMaxLevel()) // if timelogoff = 0 then it's the first login { uint32 currenttime = uint32(UNIXTIME); uint32 timediff = currenttime - plr->m_timeLogoff; //Calculate rest bonus if(timediff > 0) plr->AddCalculatedRestXP(timediff); } if(info->m_Group) info->m_Group->Update(); if(enter_world && !_player->GetMapMgr()) plr->AddToWorld(); sHookInterface.OnFullLogin(_player); objmgr.AddPlayer(_player); }
void WorldSession::FullLogin(Player * plr) { Log.Debug("WorldSession", "Fully loading player %u", plr->GetLowGUID()); SetPlayer(plr); m_MoverWoWGuid.Init(plr->GetGUID()); MapMgr *mgr = sInstanceMgr.GetInstance(static_cast< Object* >( plr )); if (mgr && mgr->m_battleground) { /* Don't allow player to login into a bg that has ended or is full */ if (mgr->m_battleground->HasEnded() == true || mgr->m_battleground->HasFreeSlots(plr->GetTeamInitial(), mgr->m_battleground->GetType() == false)) { mgr = NULL; } } /* Trying to log to an instance that doesn't exists anymore? */ if (!mgr) { if(!IS_INSTANCE(plr->m_bgEntryPointMap)) { plr->m_position.x = plr->m_bgEntryPointX; plr->m_position.y = plr->m_bgEntryPointY; plr->m_position.z = plr->m_bgEntryPointZ; plr->m_position.o = plr->m_bgEntryPointO; plr->m_mapId = plr->m_bgEntryPointMap; } else { plr->m_position.x = plr->GetBindPositionX(); plr->m_position.y = plr->GetBindPositionY(); plr->m_position.z = plr->GetBindPositionZ(); plr->m_position.o = 0; plr->m_mapId = plr->GetBindMapId(); } } // copy to movement array movement_packet[0] = m_MoverWoWGuid.GetNewGuidMask(); memcpy(&movement_packet[1], m_MoverWoWGuid.GetNewGuid(), m_MoverWoWGuid.GetNewGuidLen()); /* world preload */ packetSMSG_LOGIN_VERIFY_WORLD vwpck; vwpck.MapId = plr->GetMapId(); vwpck.O = plr->GetOrientation(); vwpck.X = plr->GetPositionX(); vwpck.Y = plr->GetPositionY(); vwpck.Z = plr->GetPositionZ(); OutPacket( SMSG_LOGIN_VERIFY_WORLD, sizeof(packetSMSG_LOGIN_VERIFY_WORLD), &vwpck ); // send voicechat state - active/inactive /* {SERVER} Packet: (0x03C7) UNKNOWN PacketSize = 2 |------------------------------------------------|----------------| |00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF| |------------------------------------------------|----------------| |02 01 |.. | ------------------------------------------------------------------- */ #ifndef USING_BIG_ENDIAN StackWorldPacket<20> datab(SMSG_VOICE_SYSTEM_STATUS); #else WorldPacket datab(SMSG_VOICE_SYSTEM_STATUS, 20); #endif #ifdef VOICE_CHAT datab.Initialize(SMSG_VOICE_SYSTEM_STATUS); datab << uint8(2) << uint8(sVoiceChatHandler.CanUseVoiceChat() ? 1 : 0); SendPacket(&datab); #else datab.Initialize(SMSG_VOICE_SYSTEM_STATUS); datab << uint8(2) << uint8(0); #endif plr->UpdateAttackSpeed(); /*if(plr->getLevel()>PLAYER_LEVEL_CAP_70) plr->SetUInt32Value(UNIT_FIELD_LEVEL,PLAYER_LEVEL_CAP_70);*/ // enable trigger cheat by default // plr->TriggerpassCheat = HasGMPermissions(); // Make sure our name exists (for premade system) PlayerInfo * info = objmgr.GetPlayerInfo(plr->GetLowGUID()); if(info == 0) { info = new PlayerInfo; info->cl = plr->getClass(); info->gender = plr->getGender(); info->guid = plr->GetLowGUID(); info->name = strdup(plr->GetName()); info->lastLevel = plr->getLevel(); info->lastOnline = UNIXTIME; info->lastZone = plr->GetZoneId(); info->race = plr->getRace(); info->team = plr->GetTeam(); info->guild=NULL; info->guildRank=NULL; info->guildMember=NULL; info->m_Group=0; info->subGroup=0; objmgr.AddPlayerInfo(info); } plr->m_playerInfo = info; if(plr->m_playerInfo->guild) { plr->m_uint32Values[PLAYER_GUILDID] = plr->m_playerInfo->guild->GetGuildId(); plr->m_uint32Values[PLAYER_GUILDRANK] = plr->m_playerInfo->guildRank->iId; } info->m_loggedInPlayer = plr; // account data == UI config #ifndef USING_BIG_ENDIAN StackWorldPacket<128> data(SMSG_ACCOUNT_DATA_MD5); #else WorldPacket data(SMSG_ACCOUNT_DATA_MD5, 128); #endif MD5Hash md5hash; for (int i = 0; i < 8; i++) { AccountDataEntry* acct_data = GetAccountData(i); if (!acct_data->data) { data << uint64(0) << uint64(0); // Nothing. continue; } md5hash.Initialize(); md5hash.UpdateData((const uint8*)acct_data->data, acct_data->sz); md5hash.Finalize(); #ifndef USING_BIG_ENDIAN data.Write(md5hash.GetDigest(), MD5_DIGEST_LENGTH); #else data.append(md5hash.GetDigest(), MD5_DIGEST_LENGTH); #endif } SendPacket(&data); // Set TIME OF LOGIN CharacterDatabase.Execute("UPDATE characters SET online = 1 WHERE guid = %u" , plr->GetLowGUID()); bool enter_world = true; #ifndef CLUSTERING // Find our transporter and add us if we're on one. if(plr->m_TransporterGUID != 0) { Transporter * pTrans = objmgr.GetTransporter(GUID_LOPART(plr->m_TransporterGUID)); if(pTrans) { if(plr->isDead()) { plr->ResurrectPlayer(); plr->SetUInt32Value(UNIT_FIELD_HEALTH, plr->GetUInt32Value(UNIT_FIELD_MAXHEALTH)); plr->SetUInt32Value(UNIT_FIELD_POWER1, plr->GetUInt32Value(UNIT_FIELD_MAXPOWER1)); } float c_tposx = pTrans->GetPositionX() + plr->m_TransporterX; float c_tposy = pTrans->GetPositionY() + plr->m_TransporterY; float c_tposz = pTrans->GetPositionZ() + plr->m_TransporterZ; if(plr->GetMapId() != pTrans->GetMapId()) // loaded wrong map { plr->SetMapId(pTrans->GetMapId()); #ifndef USING_BIG_ENDIAN StackWorldPacket<20> dataw(SMSG_NEW_WORLD); #else WorldPacket dataw(SMSG_NEW_WORLD, 20); #endif dataw << pTrans->GetMapId() << c_tposx << c_tposy << c_tposz << plr->GetOrientation(); SendPacket(&dataw); // shit is sent in worldport ack. enter_world = false; } plr->SetPosition(c_tposx, c_tposy, c_tposz, plr->GetOrientation(), false); plr->m_CurrentTransporter = pTrans; pTrans->AddPlayer(plr); } } #endif if(HasGMPermissions()) { //Toggle for admin chat color. --Hemi if(_accountId == 1) //Hemi's chat color. Greenish.. GetPlayer()->chatColor = "|cff96E798 "; else if(_accountId == 3) //Paws' chat color. Magneta. GetPlayer()->chatColor ="|cFFF52887 "; else if(CanUseCommand('z')) //Admin chat colors GetPlayer()->chatColor = MSG_COLOR_LIGHTBLUE; else if(CanUseCommand('a') && !CanUseCommand('z')) //Co-Admin chat color GetPlayer()->chatColor = MSG_COLOR_LIGHTRED; } Log.Debug("Login", "Player %s logged in.", plr->GetName()); sLog.outString("[%s] has logged in.", plr->GetName()); if(plr->GetTeam() == 1) sWorld.HordePlayers++; else sWorld.AlliancePlayers++; if(plr->m_FirstLogin && !HasGMPermissions()) { uint32 racecinematic = plr->myRace->cinematic_id; #ifdef USING_BIG_ENDIAN swap32(&racecinematic); #endif OutPacket(SMSG_TRIGGER_CINEMATIC, 4, &racecinematic); #ifdef _TEST_EXTENDED_FEATURES_ const int classtext[] ={0,5,6,8,9,11,0,4,3,7,0,10}; sWorld.SendLocalizedWorldText(true,"{65}",classtext[ (uint32)plr->getClass() ] , plr->GetName() , (plr->GetTeam() ? "{63}":"{64}") ); #endif } sLog.outDetail( "WORLD: Created new player for existing players (%s)", plr->GetName() ); // Login time, will be used for played time calc plr->m_playedtime[2] = (uint32)UNIXTIME; //Issue a message telling all guild members that this player has signed on if(plr->IsInGuild()) { Guild *pGuild = plr->m_playerInfo->guild; if(pGuild) { WorldPacket data(50); data.Initialize(SMSG_GUILD_EVENT); data << uint8(GUILD_EVENT_MOTD); data << uint8(0x01); if(pGuild->GetMOTD()) data << pGuild->GetMOTD(); else data << uint8(0); SendPacket(&data); pGuild->LogGuildEvent(GUILD_EVENT_HASCOMEONLINE, 1, plr->GetName()); } } // Send online status to people having this char in friendlist _player->Social_TellFriendsOnline(); // send friend list (for ignores) _player->Social_SendFriendList(7); #ifndef GM_TICKET_MY_MASTER_COMPATIBLE GM_Ticket * ticket = objmgr.GetGMTicketByPlayer(_player->GetGUID()); if(ticket != NULL) { //Send status change to gm_sync_channel Channel *chn = channelmgr.GetChannel(sWorld.getGmClientChannel().c_str(), _player); if(chn) { std::stringstream ss; ss << "GmTicket:" << GM_TICKET_CHAT_OPCODE_ONLINESTATE; ss << ":" << ticket->guid; ss << ":1"; chn->Say(_player, ss.str().c_str(), NULL, true); } } #endif // Send MOTD _player->BroadcastMessage(sWorld.GetMotd()); // Send revision (if enabled) #ifdef WIN32 _player->BroadcastMessage("Powered by: %sArcEmu %s r%u/%s-Win-%s %s(Please report ALL bugs to www.ArcEmu.org/forums/)", MSG_COLOR_WHITE, BUILD_TAG, BUILD_REVISION, CONFIG, ARCH, MSG_COLOR_LIGHTBLUE); #else _player->BroadcastMessage("Powered by: %sArcEmu %s r%u/%s-%s %s(Please report ALL bugs to www.ArcEmu.org/forums/)", MSG_COLOR_WHITE, BUILD_TAG, BUILD_REVISION, PLATFORM_TEXT, ARCH, MSG_COLOR_LIGHTBLUE); #endif if(sWorld.SendStatsOnJoin || HasGMPermissions() ) { _player->BroadcastMessage("Online Players: %s%u |rPeak: %s%u|r Accepted Connections: %s%u", MSG_COLOR_WHITE, sWorld.GetSessionCount(), MSG_COLOR_WHITE, sWorld.PeakSessionCount, MSG_COLOR_WHITE, sWorld.mAcceptedConnections); } //Set current RestState if( plr->m_isResting) // We are resting at an inn , turn on Zzz plr->ApplyPlayerRestState(true); //Calculate rest bonus if there is time between lastlogoff and now if( plr->m_timeLogoff > 0 && plr->GetUInt32Value(UNIT_FIELD_LEVEL) < plr->GetUInt32Value(PLAYER_FIELD_MAX_LEVEL)) // if timelogoff = 0 then it's the first login { uint32 currenttime = (uint32)UNIXTIME; uint32 timediff = currenttime - plr->m_timeLogoff; //Calculate rest bonus if( timediff > 0 ) plr->AddCalculatedRestXP(timediff); } #ifdef CLUSTERING plr->SetInstanceID(forced_instance_id); plr->SetMapId(forced_map_id); #else sHookInterface.OnEnterWorld2(_player); #endif if(info->m_Group) info->m_Group->Update(); if(enter_world && !_player->GetMapMgr()) { plr->AddToWorld(); } objmgr.AddPlayer(_player); if(info->m_Group == NULL) plr->SendDungeonDifficulty(); }
//<export/import> [zParams] void shell_xpot(int argc, TCHAR* argv[]) { int rc; int nDone = 0; int isExport = 0; TCHAR* zParams; TCHAR zSwapFile[MAX_PATH]; enum { queueBufferSize = 4096*8, }; char queueBuffer[queueBufferSize]; TransportParams* pParams; Transporter transporter; do { //(1) get input args if (argc < 2) break; if (_tcscmp(argv[1], TEXT("export")) == 0) { zParams = MULTI_PATHS_ZEXPORT; isExport = TRUE; } else if (_tcscmp(argv[1], TEXT("import")) == 0) { zParams = MULTI_PATHS_ZIMPPORT; isExport = FALSE; } else break; if (argc == 3) zParams = argv[2]; nDone = 1; //(2) init params GetModuleDir(zSwapFile, MAX_PATH); pathMng path; path.pathPush(zSwapFile, MAX_PATH, TEXT("\\fs.bin")); pParams = transporter.TransportDataInit( isExport, queueBuffer, queueBufferSize, zSwapFile, zParams ); rc = transporter.Init(pParams); if (rc) break; transporter.Start(); for (int i = 0;;i++) { TransportStatus status; transporter.GetStatus(&status); _tprintf(TEXT("status %d expl %I64d xpot %I64d\n"), status.stateFlags, status.exploredSize, status.xportedSize); if (status.stateFlags & TransportStatus::xportingComplete) break; #if (1) Sleep(500); #else //test interrupt Sleep(50); if (i==1) { transporter.Cancel(); } #endif } transporter.Final(); nDone = 2; } while(FALSE); switch (nDone) { case 2: break; case 1: _tprintf(TEXT("init fail\n")); break; default: assert(nDone == 0); _tprintf(TEXT("<export/import> [zParams]\n")); break; } }