bool Engine::update() { if (!MemoryReader::instance()->checkHandle()) { return false; } if (!MemoryReader::instance()->read(&ApplicationLoopCount, (void *)Addr_ApplicationLoopCount, sizeof(int))) { return false; } LocalData ld; if (!MemoryReader::instance()->read(&ld, (void *)Addr_LocalData, sizeof(LocalData))) { return false; } if (ld.x00_IsActorCreated > 1 || ld.x00_IsActorCreated < 0 || ld.x04_IsNotInGame > 1 || ld.x04_IsNotInGame < 0) { return false; } else { localData = ld; } if (isInGame()) { if (isObjectManagerOnNewFrame()) { update_acds(); if (nav_mesh_timer.start_or_elapsed() > 0.3) { navMesh->update(); nav_mesh_timer.start(); } } } else { acds.clear(); navMesh->clearAll(); } return true; }
//------------------------------------------------------------------------------ int Player::read(std::string& cmd) { int result = -1; if (!m_commands.empty()) { cmd = m_commands.front(); m_commands.pop(); // TODO: This should be corrected. if (isInGame() && !m_commands.empty()) { if (strncmp(m_commands.front().c_str(), "!", sizeof("!") - 1) == 0) { m_commands.push(cmd); m_commands.pop(); } } result = 0; } return result; }
// This packet actually contains the char name after the opcode void CUser::GameStart(Packet & pkt) { if (isInGame()) return; uint8 opcode = pkt.read<uint8>(); if (opcode == 1) { SendMyInfo(); g_pMain->UserInOutForMe(this); g_pMain->MerchantUserInOutForMe(this); g_pMain->NpcInOutForMe(this); SendNotice(); SendTime(); SendWeather(); // SendHackToolList(); Packet result(WIZ_GAMESTART); Send(&result); } else if (opcode == 2) { m_state = GAME_STATE_INGAME; UserInOut(INOUT_RESPAWN); if (!m_bCity && m_sHp <= 0) m_bCity = -1; if (m_bCity > 0) { int level = GetLevel(); if (m_bCity <= 100) level--; // make sure we don't exceed bounds if (level > MAX_LEVEL) level = MAX_LEVEL; else if (level < 1) level = 1; m_iLostExp = (g_pMain->GetExpByLevel(level) * (m_bCity % 10) / 100); if (((m_bCity % 10) / 100) == 1) m_iLostExp /= 2; } else { m_iLostExp = 0; } CheckSeedQuest(); BlinkStart(); SetUserAbility(); // rental RecastSavedMagic(m_sHp == m_iMaxHp ? true : false); //ItemMallRecast // If we've relogged while dead, we need to make sure the client // is still given the option to revive. if (isDead()) SendDeathAnimation(); g_pMain->TempleEventGetActiveEventTime(this); } m_tHPLastTimeNormal = UNIXTIME; }
//------------------------------------------------------------------------------ void Player::displayPrompt() { if (isInGame() && isPromptEnabled()) { m_connection->write(m_prompt.c_str(), m_prompt.length()); } }