bool stfio::exportHDF5File(const std::string& fName, const Recording& WData, ProgressInfo& progDlg) { hid_t file_id = H5Fcreate(fName.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); const int NRECORDS = 1; const int NFIELDS = 3; /* Calculate the size and the offsets of our struct members in memory */ size_t rt_offset[NFIELDS] = { HOFFSET( rt, channels ), HOFFSET( rt, date ), HOFFSET( rt, time )}; /* Define an array of root tables */ rt p_data; p_data.channels = WData.size(); struct tm t = WData.GetDateTime(); std::size_t date_length = snprintf(p_data.date, DATELEN, "%04i-%02i-%02i", t.tm_year+1900, t.tm_mon+1, t.tm_mday); std::size_t time_length = snprintf(p_data.time, TIMELEN, "%02i:%02i:%02i", t.tm_hour, t.tm_min, t.tm_sec); // ensure that an undefine string is set to "\0", and that the terminating \0 is counted in string length p_data.date[date_length++] = 0; p_data.time[time_length++] = 0; /* Define field information */ const char *field_names[NFIELDS] = { "channels", "date", "time" }; hid_t field_type[NFIELDS]; /* Initialize the field field_type */ hid_t string_type1 = H5Tcopy( H5T_C_S1 ); hid_t string_type2 = H5Tcopy( H5T_C_S1 ); H5Tset_size( string_type1, date_length); H5Tset_size( string_type2, time_length); field_type[0] = H5T_NATIVE_INT; field_type[1] = string_type1; field_type[2] = string_type2; std::ostringstream desc; desc << "Description of " << fName; herr_t status = H5TBmake_table( desc.str().c_str(), file_id, "description", (hsize_t)NFIELDS, (hsize_t)NRECORDS, sizeof(rt), field_names, rt_offset, field_type, 10, NULL, 0, &p_data ); if (status < 0) { std::string errorMsg("Exception while writing description in stfio::exportHDF5File"); H5Fclose(file_id); H5close(); throw std::runtime_error(errorMsg); } hid_t comment_group = H5Gcreate2( file_id,"/comment", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* File comment. */ std::string description(WData.GetFileDescription()); if (description.length() <= 0) { description = "No description"; } status = H5LTmake_dataset_string(file_id, "/comment/description", description.c_str()); if (status < 0) { std::string errorMsg("Exception while writing description in stfio::exportHDF5File"); H5Fclose(file_id); H5close(); throw std::runtime_error(errorMsg); } std::string comment(WData.GetComment()); if (comment.length() <= 0) { comment = "No comment"; } status = H5LTmake_dataset_string(file_id, "/comment/comment", comment.c_str()); if (status < 0) { std::string errorMsg("Exception while writing comment in stfio::exportHDF5File"); H5Fclose(file_id); H5close(); throw std::runtime_error(errorMsg); } H5Gclose(comment_group); std::vector<std::string> channel_name(WData.size()); hid_t channels_group = H5Gcreate2( file_id,"/channels", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); for ( std::size_t n_c=0; n_c < WData.size(); ++n_c) { /* Channel descriptions. */ std::ostringstream ossname; ossname << WData[n_c].GetChannelName(); if ( ossname.str() == "" ) { ossname << "ch" << (n_c); } channel_name[n_c] = ossname.str(); hsize_t dimsc[1] = { 1 }; hid_t string_typec = H5Tcopy( H5T_C_S1 ); std::size_t cn_length = channel_name[n_c].length(); if (cn_length <= 0) cn_length = 1; H5Tset_size( string_typec, cn_length ); std::vector<char> datac(channel_name[n_c].length()); std::copy(channel_name[n_c].begin(),channel_name[n_c].end(), datac.begin()); std::ostringstream desc_path; desc_path << "/channels/ch" << (n_c); status = H5LTmake_dataset(file_id, desc_path.str().c_str(), 1, dimsc, string_typec, &datac[0]); if (status < 0) { std::string errorMsg("Exception while writing channel name in stfio::exportHDF5File"); H5Fclose(file_id); H5close(); throw std::runtime_error(errorMsg); } std::ostringstream channel_path; channel_path << "/" << channel_name[n_c]; hid_t channel_group = H5Gcreate2( file_id, channel_path.str().c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (channel_group < 0) { std::ostringstream errorMsg; errorMsg << "Exception while creating channel group for " << channel_path.str().c_str(); H5Fclose(file_id); H5close(); throw std::runtime_error(errorMsg.str()); } /* Calculate the size and the offsets of our struct members in memory */ size_t ct_size = sizeof( ct ); size_t ct_offset[1] = { HOFFSET( rt, channels ) }; /* Define an array of channel tables */ ct c_data = { (int)WData[n_c].size() }; /* Define field information */ const char *cfield_names[1] = { "n_sections" }; hid_t cfield_type[1] = {H5T_NATIVE_INT}; std::ostringstream c_desc; c_desc << "Description of channel " << n_c; status = H5TBmake_table( c_desc.str().c_str(), channel_group, "description", (hsize_t)1, (hsize_t)1, ct_size, cfield_names, ct_offset, cfield_type, 10, NULL, 0, &c_data ); if (status < 0) { std::string errorMsg("Exception while writing channel description in stfio::exportHDF5File"); H5Fclose(file_id); H5close(); throw std::runtime_error(errorMsg); } int max_log10 = 0; if (WData[n_c].size() > 1) { max_log10 = int(log10((double)WData[n_c].size()-1.0)); } for (std::size_t n_s=0; n_s < WData[n_c].size(); ++n_s) { int progbar = // Channel contribution: (int)(((double)n_c/(double)WData.size())*100.0+ // Section contribution: (double)(n_s)/(double)WData[n_c].size()*(100.0/WData.size())); std::ostringstream progStr; progStr << "Writing channel #" << n_c + 1 << " of " << WData.size() << ", Section #" << n_s << " of " << WData[n_c].size(); progDlg.Update(progbar, progStr.str()); // construct a number with leading zeros: int n10 = 0; if (n_s > 0) { n10 = int(log10((double)n_s)); } std::ostringstream strZero; strZero << ""; for (int n_z=n10; n_z < max_log10; ++n_z) { strZero << "0"; } // construct a section name: std::ostringstream section_name; section_name << WData[n_c][n_s].GetSectionDescription(); if ( section_name.str() == "" ) { section_name << "sec" << n_s; } // create a child group in the channel: std::ostringstream section_path; section_path << channel_path.str() << "/" << "section_" << strZero.str() << n_s; hid_t section_group = H5Gcreate2( file_id, section_path.str().c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); // add data and description, store as 32 bit little endian independent of machine: hsize_t dims[1] = { WData[n_c][n_s].size() }; std::ostringstream data_path; data_path << section_path.str() << "/data"; Vector_float data_cp(WData[n_c][n_s].get().size()); /* 32 bit */ for (std::size_t n_cp = 0; n_cp < WData[n_c][n_s].get().size(); ++n_cp) { data_cp[n_cp] = float(WData[n_c][n_s][n_cp]); } status = H5LTmake_dataset(file_id, data_path.str().c_str(), 1, dims, H5T_IEEE_F32LE, &data_cp[0]); if (status < 0) { std::string errorMsg("Exception while writing data in stfio::exportHDF5File"); H5Fclose(file_id); H5close(); throw std::runtime_error(errorMsg); } const int NSRECORDS = 1; const int NSFIELDS = 3; /* Calculate the size and the offsets of our struct members in memory */ size_t st_size = sizeof( st ); size_t st_offset[NSFIELDS] = { HOFFSET( st, dt ), HOFFSET( st, xunits ), HOFFSET( st, yunits )}; /* Define an array of root tables */ st s_data; s_data.dt = WData.GetXScale(); if (WData.GetXUnits().length() < UNITLEN) strcpy( s_data.xunits, WData.GetXUnits().c_str() ); if (WData[n_c].GetYUnits().length() < UNITLEN) strcpy( s_data.yunits, WData[n_c].GetYUnits().c_str() ); /* Define field information */ const char *sfield_names[NSFIELDS] = { "dt", "xunits", "yunits" }; hid_t sfield_type[NSFIELDS]; /* Initialize the field field_type */ hid_t string_type4 = H5Tcopy( H5T_C_S1 ); hid_t string_type5 = H5Tcopy( H5T_C_S1 ); H5Tset_size( string_type4, 2); std::size_t yu_length = WData[n_c].GetYUnits().length(); if (yu_length <= 0) yu_length = 1; H5Tset_size( string_type5, yu_length ); sfield_type[0] = H5T_NATIVE_DOUBLE; sfield_type[1] = string_type4; sfield_type[2] = string_type5; std::ostringstream sdesc; sdesc << "Description of " << section_name.str(); status = H5TBmake_table( sdesc.str().c_str(), section_group, "description", (hsize_t)NSFIELDS, (hsize_t)NSRECORDS, st_size, sfield_names, st_offset, sfield_type, 10, NULL, 0, &s_data ); if (status < 0) { std::string errorMsg("Exception while writing section description in stfio::exportHDF5File"); H5Fclose(file_id); H5close(); throw std::runtime_error(errorMsg); } H5Gclose(section_group); } H5Gclose(channel_group); } H5Gclose(channels_group); /* Terminate access to the file. */ status = H5Fclose(file_id); if (status < 0) { std::string errorMsg("Exception while closing file in stfio::exportHDF5File"); throw std::runtime_error(errorMsg); } /* Release all hdf5 resources */ status = H5close(); if (status < 0) { std::string errorMsg("Exception while closing file in stfio::exportHDF5File"); throw std::runtime_error(errorMsg); } return (status >= 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); }