2026-02-02 12:24:50 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "core/window.hpp"
|
|
|
|
|
#include "core/input.hpp"
|
2026-02-05 14:35:12 -08:00
|
|
|
#include "game/character.hpp"
|
2026-03-07 15:46:56 -08:00
|
|
|
#include "pipeline/blp_loader.hpp"
|
2026-02-02 12:24:50 -08:00
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
2026-03-07 13:44:09 -08:00
|
|
|
#include <deque>
|
2026-02-05 21:55:52 -08:00
|
|
|
#include <unordered_map>
|
2026-02-11 18:25:04 -08:00
|
|
|
#include <unordered_set>
|
2026-02-13 20:10:19 -08:00
|
|
|
#include <array>
|
2026-03-02 08:06:35 -08:00
|
|
|
#include <optional>
|
2026-03-07 11:44:14 -08:00
|
|
|
#include <future>
|
|
|
|
|
#include <mutex>
|
2026-03-07 13:44:09 -08:00
|
|
|
#include <thread>
|
|
|
|
|
#include <atomic>
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
namespace wowee {
|
|
|
|
|
|
|
|
|
|
// Forward declarations
|
|
|
|
|
namespace rendering { class Renderer; }
|
|
|
|
|
namespace ui { class UIManager; }
|
|
|
|
|
namespace auth { class AuthHandler; }
|
2026-02-12 22:56:36 -08:00
|
|
|
namespace game { class GameHandler; class World; class ExpansionRegistry; }
|
2026-03-07 15:46:56 -08:00
|
|
|
namespace pipeline { class AssetManager; class DBCLayout; struct M2Model; struct WMOModel; }
|
2026-02-09 02:22:20 -08:00
|
|
|
namespace audio { enum class VoiceType; }
|
2026-03-20 11:12:07 -07:00
|
|
|
namespace addons { class AddonManager; }
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
namespace core {
|
|
|
|
|
|
|
|
|
|
enum class AppState {
|
|
|
|
|
AUTHENTICATION,
|
|
|
|
|
REALM_SELECTION,
|
2026-02-05 14:13:48 -08:00
|
|
|
CHARACTER_CREATION,
|
2026-02-02 12:24:50 -08:00
|
|
|
CHARACTER_SELECTION,
|
|
|
|
|
IN_GAME,
|
|
|
|
|
DISCONNECTED
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Application {
|
|
|
|
|
public:
|
|
|
|
|
Application();
|
|
|
|
|
~Application();
|
|
|
|
|
|
|
|
|
|
Application(const Application&) = delete;
|
|
|
|
|
Application& operator=(const Application&) = delete;
|
|
|
|
|
|
|
|
|
|
bool initialize();
|
|
|
|
|
void run();
|
|
|
|
|
void shutdown();
|
|
|
|
|
|
|
|
|
|
// State management
|
|
|
|
|
AppState getState() const { return state; }
|
|
|
|
|
void setState(AppState newState);
|
|
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
|
Window* getWindow() { return window.get(); }
|
|
|
|
|
rendering::Renderer* getRenderer() { return renderer.get(); }
|
|
|
|
|
ui::UIManager* getUIManager() { return uiManager.get(); }
|
|
|
|
|
auth::AuthHandler* getAuthHandler() { return authHandler.get(); }
|
|
|
|
|
game::GameHandler* getGameHandler() { return gameHandler.get(); }
|
|
|
|
|
game::World* getWorld() { return world.get(); }
|
|
|
|
|
pipeline::AssetManager* getAssetManager() { return assetManager.get(); }
|
2026-03-20 11:12:07 -07:00
|
|
|
addons::AddonManager* getAddonManager() { return addonManager_.get(); }
|
2026-02-12 22:56:36 -08:00
|
|
|
game::ExpansionRegistry* getExpansionRegistry() { return expansionRegistry_.get(); }
|
|
|
|
|
pipeline::DBCLayout* getDBCLayout() { return dbcLayout_.get(); }
|
2026-02-13 16:53:28 -08:00
|
|
|
void reloadExpansionData(); // Reload DBC layouts, opcodes, etc. after expansion change
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
// Singleton access
|
|
|
|
|
static Application& getInstance() { return *instance; }
|
|
|
|
|
|
|
|
|
|
// Weapon loading (called at spawn and on equipment change)
|
|
|
|
|
void loadEquippedWeapons();
|
|
|
|
|
|
2026-02-06 23:52:16 -08:00
|
|
|
// Logout to login screen
|
|
|
|
|
void logoutToLogin();
|
2026-02-04 18:27:52 -08:00
|
|
|
|
2026-02-06 18:34:45 -08:00
|
|
|
// Render bounds lookup (for click targeting / selection)
|
|
|
|
|
bool getRenderBoundsForGuid(uint64_t guid, glm::vec3& outCenter, float& outRadius) const;
|
2026-02-20 16:02:34 -08:00
|
|
|
bool getRenderFootZForGuid(uint64_t guid, float& outFootZ) const;
|
2026-03-10 06:33:44 -07:00
|
|
|
bool getRenderPositionForGuid(uint64_t guid, glm::vec3& outPos) const;
|
2026-02-06 18:34:45 -08:00
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
// Character skin composite state (saved at spawn for re-compositing on equipment change)
|
|
|
|
|
const std::string& getBodySkinPath() const { return bodySkinPath_; }
|
|
|
|
|
const std::vector<std::string>& getUnderwearPaths() const { return underwearPaths_; }
|
|
|
|
|
uint32_t getSkinTextureSlotIndex() const { return skinTextureSlotIndex_; }
|
|
|
|
|
uint32_t getCloakTextureSlotIndex() const { return cloakTextureSlotIndex_; }
|
2026-02-08 03:05:38 -08:00
|
|
|
uint32_t getGryphonDisplayId() const { return gryphonDisplayId_; }
|
|
|
|
|
uint32_t getWyvernDisplayId() const { return wyvernDisplayId_; }
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void update(float deltaTime);
|
|
|
|
|
void render();
|
|
|
|
|
void setupUICallbacks();
|
|
|
|
|
void spawnPlayerCharacter();
|
2026-02-05 14:35:12 -08:00
|
|
|
std::string getPlayerModelPath() const;
|
|
|
|
|
static const char* mapIdToName(uint32_t mapId);
|
2026-02-05 21:28:21 -08:00
|
|
|
void loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float z);
|
2026-02-06 17:27:20 -08:00
|
|
|
void buildFactionHostilityMap(uint8_t playerRace);
|
2026-03-07 11:44:14 -08:00
|
|
|
pipeline::M2Model loadCreatureM2Sync(const std::string& m2Path);
|
feat: propagate OBJECT_FIELD_SCALE_X through creature and GO spawn pipeline
Reads OBJECT_FIELD_SCALE_X (field 4, cross-expansion) from CREATE_OBJECT
update fields and passes it through the full creature and game object spawn
chain: game_handler callbacks → pending spawn structs → async load results
→ createInstance() calls. This gives boss giants, gnomes, children, and
other non-unit-scale NPCs correct visual size, and ensures scaled GOs
(e.g. large treasure chests, oversized plants) render at the server-specified
scale rather than always at 1.0.
- Added OBJECT_FIELD_SCALE_X to UF enum and all expansion update_fields.json
- Added float scale to CreatureSpawnCallback and GameObjectSpawnCallback
- Propagated scale through PendingCreatureSpawn, PreparedCreatureModel,
PendingGameObjectSpawn, PreparedGameObjectWMO
- Used scale in charRenderer/m2Renderer/wmoRenderer createInstance() calls
- Sanity-clamped raw float to [0.01, 100.0] range before use
2026-03-10 22:45:47 -07:00
|
|
|
void spawnOnlineCreature(uint64_t guid, uint32_t displayId, float x, float y, float z, float orientation, float scale = 1.0f);
|
2026-02-05 21:55:52 -08:00
|
|
|
void despawnOnlineCreature(uint64_t guid);
|
2026-02-20 23:04:57 -08:00
|
|
|
bool tryAttachCreatureVirtualWeapons(uint64_t guid, uint32_t instanceId);
|
2026-02-13 19:40:54 -08:00
|
|
|
void spawnOnlinePlayer(uint64_t guid,
|
|
|
|
|
uint8_t raceId,
|
|
|
|
|
uint8_t genderId,
|
|
|
|
|
uint32_t appearanceBytes,
|
|
|
|
|
uint8_t facialFeatures,
|
|
|
|
|
float x, float y, float z, float orientation);
|
2026-02-13 20:10:19 -08:00
|
|
|
void setOnlinePlayerEquipment(uint64_t guid,
|
|
|
|
|
const std::array<uint32_t, 19>& displayInfoIds,
|
|
|
|
|
const std::array<uint8_t, 19>& inventoryTypes);
|
2026-02-13 19:40:54 -08:00
|
|
|
void despawnOnlinePlayer(uint64_t guid);
|
2026-02-05 21:55:52 -08:00
|
|
|
void buildCreatureDisplayLookups();
|
|
|
|
|
std::string getModelPathForDisplayId(uint32_t displayId) const;
|
feat: propagate OBJECT_FIELD_SCALE_X through creature and GO spawn pipeline
Reads OBJECT_FIELD_SCALE_X (field 4, cross-expansion) from CREATE_OBJECT
update fields and passes it through the full creature and game object spawn
chain: game_handler callbacks → pending spawn structs → async load results
→ createInstance() calls. This gives boss giants, gnomes, children, and
other non-unit-scale NPCs correct visual size, and ensures scaled GOs
(e.g. large treasure chests, oversized plants) render at the server-specified
scale rather than always at 1.0.
- Added OBJECT_FIELD_SCALE_X to UF enum and all expansion update_fields.json
- Added float scale to CreatureSpawnCallback and GameObjectSpawnCallback
- Propagated scale through PendingCreatureSpawn, PreparedCreatureModel,
PendingGameObjectSpawn, PreparedGameObjectWMO
- Used scale in charRenderer/m2Renderer/wmoRenderer createInstance() calls
- Sanity-clamped raw float to [0.01, 100.0] range before use
2026-03-10 22:45:47 -07:00
|
|
|
void spawnOnlineGameObject(uint64_t guid, uint32_t entry, uint32_t displayId, float x, float y, float z, float orientation, float scale = 1.0f);
|
2026-02-07 19:44:03 -08:00
|
|
|
void despawnOnlineGameObject(uint64_t guid);
|
|
|
|
|
void buildGameObjectDisplayLookups();
|
|
|
|
|
std::string getGameObjectModelPathForDisplayId(uint32_t displayId) const;
|
2026-02-09 02:22:20 -08:00
|
|
|
audio::VoiceType detectVoiceTypeFromDisplayId(uint32_t displayId) const;
|
2026-02-10 21:29:10 -08:00
|
|
|
void setupTestTransport(); // Test transport boat for development
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
static Application* instance;
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<Window> window;
|
|
|
|
|
std::unique_ptr<rendering::Renderer> renderer;
|
|
|
|
|
std::unique_ptr<ui::UIManager> uiManager;
|
|
|
|
|
std::unique_ptr<auth::AuthHandler> authHandler;
|
|
|
|
|
std::unique_ptr<game::GameHandler> gameHandler;
|
|
|
|
|
std::unique_ptr<game::World> world;
|
|
|
|
|
std::unique_ptr<pipeline::AssetManager> assetManager;
|
2026-03-20 11:12:07 -07:00
|
|
|
std::unique_ptr<addons::AddonManager> addonManager_;
|
|
|
|
|
bool addonsLoaded_ = false;
|
2026-02-12 22:56:36 -08:00
|
|
|
std::unique_ptr<game::ExpansionRegistry> expansionRegistry_;
|
|
|
|
|
std::unique_ptr<pipeline::DBCLayout> dbcLayout_;
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
AppState state = AppState::AUTHENTICATION;
|
|
|
|
|
bool running = false;
|
2026-02-09 22:51:13 -08:00
|
|
|
std::string pendingCreatedCharacterName_; // Auto-select after character creation
|
2026-02-02 12:24:50 -08:00
|
|
|
bool playerCharacterSpawned = false;
|
|
|
|
|
bool npcsSpawned = false;
|
2026-02-04 23:30:03 -08:00
|
|
|
bool spawnSnapToGround = true;
|
2026-02-02 12:24:50 -08:00
|
|
|
float lastFrameTime = 0.0f;
|
|
|
|
|
|
2026-02-07 11:26:49 -08:00
|
|
|
// Player character info (for model spawning)
|
|
|
|
|
game::Race playerRace_ = game::Race::HUMAN;
|
|
|
|
|
game::Gender playerGender_ = game::Gender::MALE;
|
|
|
|
|
game::Class playerClass_ = game::Class::WARRIOR;
|
2026-02-12 14:55:27 -08:00
|
|
|
uint64_t spawnedPlayerGuid_ = 0;
|
|
|
|
|
uint32_t spawnedAppearanceBytes_ = 0;
|
|
|
|
|
uint8_t spawnedFacialFeatures_ = 0;
|
2026-02-07 11:26:49 -08:00
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
// Weapon model ID counter (starting high to avoid collision with character model IDs)
|
|
|
|
|
uint32_t nextWeaponModelId_ = 1000;
|
|
|
|
|
|
|
|
|
|
// Saved at spawn for skin re-compositing
|
|
|
|
|
std::string bodySkinPath_;
|
|
|
|
|
std::vector<std::string> underwearPaths_;
|
|
|
|
|
uint32_t skinTextureSlotIndex_ = 0;
|
|
|
|
|
uint32_t cloakTextureSlotIndex_ = 0;
|
2026-02-05 21:55:52 -08:00
|
|
|
|
|
|
|
|
// Online creature model spawning
|
2026-02-05 22:47:21 -08:00
|
|
|
struct CreatureDisplayData {
|
|
|
|
|
uint32_t modelId = 0;
|
|
|
|
|
std::string skin1, skin2, skin3; // Texture names from CreatureDisplayInfo.dbc
|
|
|
|
|
uint32_t extraDisplayId = 0; // Link to CreatureDisplayInfoExtra.dbc
|
|
|
|
|
};
|
|
|
|
|
struct HumanoidDisplayExtra {
|
|
|
|
|
uint8_t raceId = 0;
|
|
|
|
|
uint8_t sexId = 0;
|
|
|
|
|
uint8_t skinId = 0;
|
|
|
|
|
uint8_t faceId = 0;
|
|
|
|
|
uint8_t hairStyleId = 0;
|
|
|
|
|
uint8_t hairColorId = 0;
|
|
|
|
|
uint8_t facialHairId = 0;
|
|
|
|
|
std::string bakeName; // Pre-baked texture path if available
|
2026-02-05 22:57:32 -08:00
|
|
|
// Equipment display IDs (from columns 8-18)
|
|
|
|
|
// 0=helm, 1=shoulder, 2=shirt, 3=chest, 4=belt, 5=legs, 6=feet, 7=wrist, 8=hands, 9=tabard, 10=cape
|
|
|
|
|
uint32_t equipDisplayId[11] = {0};
|
2026-02-05 22:47:21 -08:00
|
|
|
};
|
|
|
|
|
std::unordered_map<uint32_t, CreatureDisplayData> displayDataMap_; // displayId → display data
|
|
|
|
|
std::unordered_map<uint32_t, HumanoidDisplayExtra> humanoidExtraMap_; // extraDisplayId → humanoid data
|
2026-02-05 21:55:52 -08:00
|
|
|
std::unordered_map<uint32_t, std::string> modelIdToPath_; // modelId → M2 path (from CreatureModelData.dbc)
|
2026-02-06 01:02:35 -08:00
|
|
|
// CharHairGeosets.dbc: key = (raceId<<16)|(sexId<<8)|variationId → geosetId (skinSectionId)
|
|
|
|
|
std::unordered_map<uint32_t, uint16_t> hairGeosetMap_;
|
|
|
|
|
// CharFacialHairStyles.dbc: key = (raceId<<16)|(sexId<<8)|variationId → {geoset100, geoset300, geoset200}
|
|
|
|
|
struct FacialHairGeosets { uint16_t geoset100 = 0; uint16_t geoset300 = 0; uint16_t geoset200 = 0; };
|
|
|
|
|
std::unordered_map<uint32_t, FacialHairGeosets> facialHairGeosetMap_;
|
2026-02-05 21:55:52 -08:00
|
|
|
std::unordered_map<uint64_t, uint32_t> creatureInstances_; // guid → render instanceId
|
|
|
|
|
std::unordered_map<uint64_t, uint32_t> creatureModelIds_; // guid → loaded modelId
|
2026-02-20 16:40:22 -08:00
|
|
|
std::unordered_map<uint64_t, glm::vec3> creatureRenderPosCache_; // guid -> last synced render position
|
2026-03-10 12:03:33 -07:00
|
|
|
std::unordered_map<uint64_t, bool> creatureWasMoving_; // guid -> previous-frame movement state
|
|
|
|
|
std::unordered_map<uint64_t, bool> creatureWasSwimming_; // guid -> previous-frame swim state (for anim transition detection)
|
|
|
|
|
std::unordered_map<uint64_t, bool> creatureWasFlying_; // guid -> previous-frame flying state (for anim transition detection)
|
2026-03-10 12:04:59 -07:00
|
|
|
std::unordered_map<uint64_t, bool> creatureWasWalking_; // guid -> previous-frame walking state (walk vs run transition detection)
|
2026-03-10 10:55:23 -07:00
|
|
|
std::unordered_map<uint64_t, bool> creatureSwimmingState_; // guid -> currently in swim mode (SWIMMING flag)
|
|
|
|
|
std::unordered_map<uint64_t, bool> creatureWalkingState_; // guid -> walking (WALKING flag, selects Walk(4) vs Run(5))
|
2026-03-10 11:56:50 -07:00
|
|
|
std::unordered_map<uint64_t, bool> creatureFlyingState_; // guid -> currently flying (FLYING flag)
|
2026-02-20 23:04:57 -08:00
|
|
|
std::unordered_set<uint64_t> creatureWeaponsAttached_; // guid set when NPC virtual weapons attached
|
|
|
|
|
std::unordered_map<uint64_t, uint8_t> creatureWeaponAttachAttempts_; // guid -> attach attempts
|
2026-03-07 11:44:14 -08:00
|
|
|
std::unordered_map<uint32_t, bool> modelIdIsWolfLike_; // modelId → cached wolf/worg check
|
|
|
|
|
static constexpr int MAX_WEAPON_ATTACHES_PER_TICK = 2; // limit weapon attach work per 1s tick
|
|
|
|
|
|
|
|
|
|
// CharSections.dbc lookup cache to avoid O(N) DBC scan per NPC spawn.
|
|
|
|
|
// Key: (race<<24)|(sex<<16)|(section<<12)|(variation<<8)|color → texture path
|
|
|
|
|
std::unordered_map<uint64_t, std::string> charSectionsCache_;
|
|
|
|
|
bool charSectionsCacheBuilt_ = false;
|
|
|
|
|
void buildCharSectionsCache();
|
|
|
|
|
std::string lookupCharSection(uint8_t race, uint8_t sex, uint8_t section,
|
|
|
|
|
uint8_t variation, uint8_t color, int texIndex = 0) const;
|
|
|
|
|
|
|
|
|
|
// Async creature model loading: file I/O + M2 parsing on background thread,
|
|
|
|
|
// GPU upload + instance creation on main thread.
|
|
|
|
|
struct PreparedCreatureModel {
|
|
|
|
|
uint64_t guid;
|
|
|
|
|
uint32_t displayId;
|
|
|
|
|
uint32_t modelId;
|
|
|
|
|
float x, y, z, orientation;
|
feat: propagate OBJECT_FIELD_SCALE_X through creature and GO spawn pipeline
Reads OBJECT_FIELD_SCALE_X (field 4, cross-expansion) from CREATE_OBJECT
update fields and passes it through the full creature and game object spawn
chain: game_handler callbacks → pending spawn structs → async load results
→ createInstance() calls. This gives boss giants, gnomes, children, and
other non-unit-scale NPCs correct visual size, and ensures scaled GOs
(e.g. large treasure chests, oversized plants) render at the server-specified
scale rather than always at 1.0.
- Added OBJECT_FIELD_SCALE_X to UF enum and all expansion update_fields.json
- Added float scale to CreatureSpawnCallback and GameObjectSpawnCallback
- Propagated scale through PendingCreatureSpawn, PreparedCreatureModel,
PendingGameObjectSpawn, PreparedGameObjectWMO
- Used scale in charRenderer/m2Renderer/wmoRenderer createInstance() calls
- Sanity-clamped raw float to [0.01, 100.0] range before use
2026-03-10 22:45:47 -07:00
|
|
|
float scale = 1.0f;
|
2026-03-07 11:44:14 -08:00
|
|
|
std::shared_ptr<pipeline::M2Model> model; // parsed on background thread
|
2026-03-07 15:46:56 -08:00
|
|
|
std::unordered_map<std::string, pipeline::BLPImage> predecodedTextures; // decoded on bg thread
|
2026-03-07 11:44:14 -08:00
|
|
|
bool valid = false;
|
|
|
|
|
bool permanent_failure = false;
|
|
|
|
|
};
|
|
|
|
|
struct AsyncCreatureLoad {
|
|
|
|
|
std::future<PreparedCreatureModel> future;
|
|
|
|
|
};
|
|
|
|
|
std::vector<AsyncCreatureLoad> asyncCreatureLoads_;
|
2026-03-15 01:21:23 -07:00
|
|
|
std::unordered_set<uint32_t> asyncCreatureDisplayLoads_; // displayIds currently loading in background
|
2026-03-07 17:31:47 -08:00
|
|
|
void processAsyncCreatureResults(bool unlimited = false);
|
2026-03-07 11:44:14 -08:00
|
|
|
static constexpr int MAX_ASYNC_CREATURE_LOADS = 4; // concurrent background loads
|
2026-02-19 01:19:29 -08:00
|
|
|
std::unordered_set<uint64_t> deadCreatureGuids_; // GUIDs that should spawn in corpse/death pose
|
2026-02-06 13:47:03 -08:00
|
|
|
std::unordered_map<uint32_t, uint32_t> displayIdModelCache_; // displayId → modelId (model caching)
|
2026-03-07 11:44:14 -08:00
|
|
|
std::unordered_set<uint32_t> displayIdTexturesApplied_; // displayIds with per-model textures applied
|
2026-03-07 16:54:58 -08:00
|
|
|
std::unordered_map<uint32_t, std::unordered_map<std::string, pipeline::BLPImage>> displayIdPredecodedTextures_; // displayId → pre-decoded skin textures
|
2026-02-21 02:43:06 -08:00
|
|
|
mutable std::unordered_set<uint32_t> warnedMissingDisplayDataIds_; // displayIds already warned
|
|
|
|
|
mutable std::unordered_set<uint32_t> warnedMissingModelPathIds_; // modelIds/displayIds already warned
|
2026-02-05 21:55:52 -08:00
|
|
|
uint32_t nextCreatureModelId_ = 5000; // Model IDs for online creatures
|
2026-02-08 03:05:38 -08:00
|
|
|
uint32_t gryphonDisplayId_ = 0;
|
|
|
|
|
uint32_t wyvernDisplayId_ = 0;
|
|
|
|
|
bool lastTaxiFlight_ = false;
|
2026-02-17 02:23:41 -08:00
|
|
|
uint32_t loadedMapId_ = 0xFFFFFFFF; // Map ID of currently loaded terrain (0xFFFFFFFF = none)
|
2026-03-02 08:06:35 -08:00
|
|
|
uint32_t worldLoadGeneration_ = 0; // Incremented on each world entry to detect re-entrant loads
|
|
|
|
|
bool loadingWorld_ = false; // True while loadOnlineWorldTerrain is running
|
|
|
|
|
struct PendingWorldEntry {
|
|
|
|
|
uint32_t mapId; float x, y, z;
|
|
|
|
|
};
|
|
|
|
|
std::optional<PendingWorldEntry> pendingWorldEntry_; // Deferred world entry during loading
|
2026-02-11 21:14:35 -08:00
|
|
|
float taxiLandingClampTimer_ = 0.0f;
|
|
|
|
|
float worldEntryMovementGraceTimer_ = 0.0f;
|
2026-03-07 22:03:28 -08:00
|
|
|
|
|
|
|
|
// Hearth teleport: freeze player until terrain loads at destination
|
|
|
|
|
bool hearthTeleportPending_ = false;
|
|
|
|
|
glm::vec3 hearthTeleportPos_{0.0f}; // render coords
|
|
|
|
|
float hearthTeleportTimer_ = 0.0f; // timeout safety
|
2026-02-20 02:50:59 -08:00
|
|
|
float facingSendCooldown_ = 0.0f; // Rate-limits MSG_MOVE_SET_FACING
|
2026-02-19 16:40:17 -08:00
|
|
|
float lastSentCanonicalYaw_ = 1000.0f; // Sentinel — triggers first send
|
2026-02-08 03:05:38 -08:00
|
|
|
float taxiStreamCooldown_ = 0.0f;
|
2026-02-08 03:39:02 -08:00
|
|
|
bool idleYawned_ = false;
|
2026-02-07 17:59:40 -08:00
|
|
|
|
2026-02-19 21:13:13 -08:00
|
|
|
// Charge rush state
|
|
|
|
|
bool chargeActive_ = false;
|
|
|
|
|
float chargeTimer_ = 0.0f;
|
|
|
|
|
float chargeDuration_ = 0.0f;
|
|
|
|
|
glm::vec3 chargeStartPos_{0.0f}; // Render coordinates
|
|
|
|
|
glm::vec3 chargeEndPos_{0.0f}; // Render coordinates
|
|
|
|
|
uint64_t chargeTargetGuid_ = 0;
|
|
|
|
|
|
2026-02-07 19:44:03 -08:00
|
|
|
// Online gameobject model spawning
|
|
|
|
|
struct GameObjectInstanceInfo {
|
|
|
|
|
uint32_t modelId = 0;
|
|
|
|
|
uint32_t instanceId = 0;
|
|
|
|
|
bool isWmo = false;
|
|
|
|
|
};
|
|
|
|
|
std::unordered_map<uint32_t, std::string> gameObjectDisplayIdToPath_;
|
|
|
|
|
std::unordered_map<uint32_t, uint32_t> gameObjectDisplayIdModelCache_; // displayId → M2 modelId
|
2026-03-13 01:45:31 -07:00
|
|
|
std::unordered_set<uint32_t> gameObjectDisplayIdFailedCache_; // displayIds that permanently fail to load
|
2026-02-07 19:44:03 -08:00
|
|
|
std::unordered_map<uint32_t, uint32_t> gameObjectDisplayIdWmoCache_; // displayId → WMO modelId
|
|
|
|
|
std::unordered_map<uint64_t, GameObjectInstanceInfo> gameObjectInstances_; // guid → instance info
|
2026-02-12 00:14:39 -08:00
|
|
|
struct PendingTransportMove {
|
|
|
|
|
float x = 0.0f;
|
|
|
|
|
float y = 0.0f;
|
|
|
|
|
float z = 0.0f;
|
|
|
|
|
float orientation = 0.0f;
|
|
|
|
|
};
|
2026-03-15 01:21:23 -07:00
|
|
|
struct PendingTransportRegistration {
|
|
|
|
|
uint64_t guid = 0;
|
|
|
|
|
uint32_t entry = 0;
|
|
|
|
|
uint32_t displayId = 0;
|
|
|
|
|
float x = 0.0f;
|
|
|
|
|
float y = 0.0f;
|
|
|
|
|
float z = 0.0f;
|
|
|
|
|
float orientation = 0.0f;
|
|
|
|
|
};
|
2026-02-12 00:14:39 -08:00
|
|
|
std::unordered_map<uint64_t, PendingTransportMove> pendingTransportMoves_; // guid -> latest pre-registration move
|
2026-03-15 01:21:23 -07:00
|
|
|
std::deque<PendingTransportRegistration> pendingTransportRegistrations_;
|
2026-02-07 19:44:03 -08:00
|
|
|
uint32_t nextGameObjectModelId_ = 20000;
|
|
|
|
|
uint32_t nextGameObjectWmoModelId_ = 40000;
|
2026-02-20 17:29:09 -08:00
|
|
|
bool testTransportSetup_ = false;
|
2026-02-07 19:44:03 -08:00
|
|
|
bool gameObjectLookupsBuilt_ = false;
|
|
|
|
|
|
2026-02-07 17:59:40 -08:00
|
|
|
// Mount model tracking
|
|
|
|
|
uint32_t mountInstanceId_ = 0;
|
|
|
|
|
uint32_t mountModelId_ = 0;
|
2026-02-07 18:33:14 -08:00
|
|
|
uint32_t pendingMountDisplayId_ = 0; // Deferred mount load (0 = none pending)
|
2026-02-12 00:14:39 -08:00
|
|
|
bool weaponsSheathed_ = false;
|
2026-02-12 00:15:51 -08:00
|
|
|
bool wasAutoAttacking_ = false;
|
2026-02-07 18:33:14 -08:00
|
|
|
void processPendingMount();
|
2026-02-05 21:55:52 -08:00
|
|
|
bool creatureLookupsBuilt_ = false;
|
2026-02-14 00:00:26 -08:00
|
|
|
bool mapNameCacheLoaded_ = false;
|
|
|
|
|
std::unordered_map<uint32_t, std::string> mapNameById_;
|
2026-02-06 13:47:03 -08:00
|
|
|
|
|
|
|
|
// Deferred creature spawn queue (throttles spawning to avoid hangs)
|
|
|
|
|
struct PendingCreatureSpawn {
|
|
|
|
|
uint64_t guid;
|
|
|
|
|
uint32_t displayId;
|
|
|
|
|
float x, y, z, orientation;
|
feat: propagate OBJECT_FIELD_SCALE_X through creature and GO spawn pipeline
Reads OBJECT_FIELD_SCALE_X (field 4, cross-expansion) from CREATE_OBJECT
update fields and passes it through the full creature and game object spawn
chain: game_handler callbacks → pending spawn structs → async load results
→ createInstance() calls. This gives boss giants, gnomes, children, and
other non-unit-scale NPCs correct visual size, and ensures scaled GOs
(e.g. large treasure chests, oversized plants) render at the server-specified
scale rather than always at 1.0.
- Added OBJECT_FIELD_SCALE_X to UF enum and all expansion update_fields.json
- Added float scale to CreatureSpawnCallback and GameObjectSpawnCallback
- Propagated scale through PendingCreatureSpawn, PreparedCreatureModel,
PendingGameObjectSpawn, PreparedGameObjectWMO
- Used scale in charRenderer/m2Renderer/wmoRenderer createInstance() calls
- Sanity-clamped raw float to [0.01, 100.0] range before use
2026-03-10 22:45:47 -07:00
|
|
|
float scale = 1.0f;
|
2026-02-06 13:47:03 -08:00
|
|
|
};
|
2026-03-07 13:44:09 -08:00
|
|
|
std::deque<PendingCreatureSpawn> pendingCreatureSpawns_;
|
2026-02-25 12:16:55 -08:00
|
|
|
static constexpr int MAX_SPAWNS_PER_FRAME = 3;
|
2026-02-20 20:00:44 -08:00
|
|
|
static constexpr int MAX_NEW_CREATURE_MODELS_PER_FRAME = 1;
|
2026-02-11 18:25:04 -08:00
|
|
|
static constexpr uint16_t MAX_CREATURE_SPAWN_RETRIES = 300;
|
|
|
|
|
std::unordered_set<uint64_t> pendingCreatureSpawnGuids_;
|
|
|
|
|
std::unordered_map<uint64_t, uint16_t> creatureSpawnRetryCounts_;
|
|
|
|
|
std::unordered_set<uint32_t> nonRenderableCreatureDisplayIds_;
|
2026-02-13 19:40:54 -08:00
|
|
|
|
|
|
|
|
// Online player instances (separate from creatures so we can apply per-player skin/hair textures).
|
|
|
|
|
std::unordered_map<uint64_t, uint32_t> playerInstances_; // guid → render instanceId
|
2026-02-13 20:10:19 -08:00
|
|
|
struct OnlinePlayerAppearanceState {
|
|
|
|
|
uint32_t instanceId = 0;
|
|
|
|
|
uint32_t modelId = 0;
|
|
|
|
|
uint8_t raceId = 0;
|
|
|
|
|
uint8_t genderId = 0;
|
|
|
|
|
uint32_t appearanceBytes = 0;
|
|
|
|
|
uint8_t facialFeatures = 0;
|
|
|
|
|
std::string bodySkinPath;
|
|
|
|
|
std::vector<std::string> underwearPaths;
|
|
|
|
|
};
|
|
|
|
|
std::unordered_map<uint64_t, OnlinePlayerAppearanceState> onlinePlayerAppearance_;
|
|
|
|
|
std::unordered_map<uint64_t, std::pair<std::array<uint32_t, 19>, std::array<uint8_t, 19>>> pendingOnlinePlayerEquipment_;
|
2026-02-16 00:51:59 -08:00
|
|
|
// Deferred equipment compositing queue — processes max 1 per frame to avoid stutter
|
|
|
|
|
std::vector<std::pair<uint64_t, std::pair<std::array<uint32_t, 19>, std::array<uint8_t, 19>>>> deferredEquipmentQueue_;
|
|
|
|
|
void processDeferredEquipmentQueue();
|
2026-03-07 16:54:58 -08:00
|
|
|
// Async equipment texture pre-decode: BLP decode on background thread, composite on main thread
|
|
|
|
|
struct PreparedEquipmentUpdate {
|
|
|
|
|
uint64_t guid;
|
|
|
|
|
std::array<uint32_t, 19> displayInfoIds;
|
|
|
|
|
std::array<uint8_t, 19> inventoryTypes;
|
|
|
|
|
std::unordered_map<std::string, pipeline::BLPImage> predecodedTextures;
|
|
|
|
|
};
|
|
|
|
|
struct AsyncEquipmentLoad {
|
|
|
|
|
std::future<PreparedEquipmentUpdate> future;
|
|
|
|
|
};
|
|
|
|
|
std::vector<AsyncEquipmentLoad> asyncEquipmentLoads_;
|
|
|
|
|
void processAsyncEquipmentResults();
|
|
|
|
|
std::vector<std::string> resolveEquipmentTexturePaths(uint64_t guid,
|
|
|
|
|
const std::array<uint32_t, 19>& displayInfoIds,
|
|
|
|
|
const std::array<uint8_t, 19>& inventoryTypes) const;
|
|
|
|
|
// Deferred NPC texture setup — async DBC lookups + BLP pre-decode to avoid main-thread stalls
|
|
|
|
|
struct DeferredNpcComposite {
|
|
|
|
|
uint32_t modelId;
|
|
|
|
|
uint32_t displayId;
|
|
|
|
|
// Skin compositing (type-1 slots)
|
|
|
|
|
std::string basePath; // CharSections skin base texture
|
|
|
|
|
std::vector<std::string> overlayPaths; // face + underwear overlays
|
|
|
|
|
std::vector<std::pair<int, std::string>> regionLayers; // equipment region overlays
|
|
|
|
|
std::vector<uint32_t> skinTextureSlots; // model texture slots needing skin composite
|
|
|
|
|
bool hasComposite = false; // needs compositing (overlays or equipment regions)
|
|
|
|
|
bool hasSimpleSkin = false; // just base skin, no compositing needed
|
|
|
|
|
// Baked skin (type-1 slots)
|
|
|
|
|
std::string bakedSkinPath; // baked texture path (if available)
|
|
|
|
|
bool hasBakedSkin = false; // baked skin resolved successfully
|
|
|
|
|
// Hair (type-6 slots)
|
|
|
|
|
std::vector<uint32_t> hairTextureSlots; // model texture slots needing hair texture
|
|
|
|
|
std::string hairTexturePath; // resolved hair texture path
|
|
|
|
|
bool useBakedForHair = false; // bald NPC: use baked skin for type-6
|
|
|
|
|
};
|
|
|
|
|
struct PreparedNpcComposite {
|
|
|
|
|
DeferredNpcComposite info;
|
|
|
|
|
std::unordered_map<std::string, pipeline::BLPImage> predecodedTextures;
|
|
|
|
|
};
|
|
|
|
|
struct AsyncNpcCompositeLoad {
|
|
|
|
|
std::future<PreparedNpcComposite> future;
|
|
|
|
|
};
|
|
|
|
|
std::vector<AsyncNpcCompositeLoad> asyncNpcCompositeLoads_;
|
2026-03-10 06:47:33 -07:00
|
|
|
void processAsyncNpcCompositeResults(bool unlimited = false);
|
2026-02-13 19:40:54 -08:00
|
|
|
// Cache base player model geometry by (raceId, genderId)
|
|
|
|
|
std::unordered_map<uint32_t, uint32_t> playerModelCache_; // key=(race<<8)|gender → modelId
|
|
|
|
|
struct PlayerTextureSlots { int skin = -1; int hair = -1; int underwear = -1; };
|
|
|
|
|
std::unordered_map<uint32_t, PlayerTextureSlots> playerTextureSlotsByModelId_;
|
|
|
|
|
uint32_t nextPlayerModelId_ = 60000;
|
|
|
|
|
struct PendingPlayerSpawn {
|
|
|
|
|
uint64_t guid;
|
|
|
|
|
uint8_t raceId;
|
|
|
|
|
uint8_t genderId;
|
|
|
|
|
uint32_t appearanceBytes;
|
|
|
|
|
uint8_t facialFeatures;
|
|
|
|
|
float x, y, z, orientation;
|
|
|
|
|
};
|
|
|
|
|
std::vector<PendingPlayerSpawn> pendingPlayerSpawns_;
|
|
|
|
|
std::unordered_set<uint64_t> pendingPlayerSpawnGuids_;
|
|
|
|
|
void processPlayerSpawnQueue();
|
2026-02-11 18:25:04 -08:00
|
|
|
std::unordered_set<uint64_t> creaturePermanentFailureGuids_;
|
2026-03-07 17:31:47 -08:00
|
|
|
void processCreatureSpawnQueue(bool unlimited = false);
|
2026-02-07 19:44:03 -08:00
|
|
|
|
|
|
|
|
struct PendingGameObjectSpawn {
|
|
|
|
|
uint64_t guid;
|
2026-02-11 00:54:38 -08:00
|
|
|
uint32_t entry;
|
2026-02-07 19:44:03 -08:00
|
|
|
uint32_t displayId;
|
|
|
|
|
float x, y, z, orientation;
|
feat: propagate OBJECT_FIELD_SCALE_X through creature and GO spawn pipeline
Reads OBJECT_FIELD_SCALE_X (field 4, cross-expansion) from CREATE_OBJECT
update fields and passes it through the full creature and game object spawn
chain: game_handler callbacks → pending spawn structs → async load results
→ createInstance() calls. This gives boss giants, gnomes, children, and
other non-unit-scale NPCs correct visual size, and ensures scaled GOs
(e.g. large treasure chests, oversized plants) render at the server-specified
scale rather than always at 1.0.
- Added OBJECT_FIELD_SCALE_X to UF enum and all expansion update_fields.json
- Added float scale to CreatureSpawnCallback and GameObjectSpawnCallback
- Propagated scale through PendingCreatureSpawn, PreparedCreatureModel,
PendingGameObjectSpawn, PreparedGameObjectWMO
- Used scale in charRenderer/m2Renderer/wmoRenderer createInstance() calls
- Sanity-clamped raw float to [0.01, 100.0] range before use
2026-03-10 22:45:47 -07:00
|
|
|
float scale = 1.0f;
|
2026-02-07 19:44:03 -08:00
|
|
|
};
|
|
|
|
|
std::vector<PendingGameObjectSpawn> pendingGameObjectSpawns_;
|
|
|
|
|
void processGameObjectSpawnQueue();
|
2026-03-07 15:46:56 -08:00
|
|
|
|
|
|
|
|
// Async WMO loading for game objects (file I/O + parse on background thread)
|
|
|
|
|
struct PreparedGameObjectWMO {
|
|
|
|
|
uint64_t guid;
|
|
|
|
|
uint32_t entry;
|
|
|
|
|
uint32_t displayId;
|
|
|
|
|
float x, y, z, orientation;
|
feat: propagate OBJECT_FIELD_SCALE_X through creature and GO spawn pipeline
Reads OBJECT_FIELD_SCALE_X (field 4, cross-expansion) from CREATE_OBJECT
update fields and passes it through the full creature and game object spawn
chain: game_handler callbacks → pending spawn structs → async load results
→ createInstance() calls. This gives boss giants, gnomes, children, and
other non-unit-scale NPCs correct visual size, and ensures scaled GOs
(e.g. large treasure chests, oversized plants) render at the server-specified
scale rather than always at 1.0.
- Added OBJECT_FIELD_SCALE_X to UF enum and all expansion update_fields.json
- Added float scale to CreatureSpawnCallback and GameObjectSpawnCallback
- Propagated scale through PendingCreatureSpawn, PreparedCreatureModel,
PendingGameObjectSpawn, PreparedGameObjectWMO
- Used scale in charRenderer/m2Renderer/wmoRenderer createInstance() calls
- Sanity-clamped raw float to [0.01, 100.0] range before use
2026-03-10 22:45:47 -07:00
|
|
|
float scale = 1.0f;
|
2026-03-07 15:46:56 -08:00
|
|
|
std::shared_ptr<pipeline::WMOModel> wmoModel;
|
|
|
|
|
std::unordered_map<std::string, pipeline::BLPImage> predecodedTextures; // decoded on bg thread
|
|
|
|
|
bool valid = false;
|
|
|
|
|
bool isWmo = false;
|
|
|
|
|
std::string modelPath;
|
|
|
|
|
};
|
|
|
|
|
struct AsyncGameObjectLoad {
|
|
|
|
|
std::future<PreparedGameObjectWMO> future;
|
|
|
|
|
};
|
|
|
|
|
std::vector<AsyncGameObjectLoad> asyncGameObjectLoads_;
|
|
|
|
|
void processAsyncGameObjectResults();
|
2026-02-20 20:00:44 -08:00
|
|
|
struct PendingTransportDoodadBatch {
|
|
|
|
|
uint64_t guid = 0;
|
|
|
|
|
uint32_t modelId = 0;
|
|
|
|
|
uint32_t instanceId = 0;
|
|
|
|
|
size_t nextIndex = 0;
|
|
|
|
|
size_t doodadBudget = 0;
|
|
|
|
|
size_t spawnedDoodads = 0;
|
|
|
|
|
float x = 0.0f;
|
|
|
|
|
float y = 0.0f;
|
|
|
|
|
float z = 0.0f;
|
|
|
|
|
float orientation = 0.0f;
|
|
|
|
|
};
|
|
|
|
|
std::vector<PendingTransportDoodadBatch> pendingTransportDoodadBatches_;
|
2026-02-20 20:31:04 -08:00
|
|
|
static constexpr size_t MAX_TRANSPORT_DOODADS_PER_FRAME = 4;
|
2026-03-15 01:21:23 -07:00
|
|
|
void processPendingTransportRegistrations();
|
2026-02-20 20:00:44 -08:00
|
|
|
void processPendingTransportDoodads();
|
2026-02-09 23:05:23 -08:00
|
|
|
|
2026-02-09 23:41:38 -08:00
|
|
|
// Quest marker billboard sprites (above NPCs)
|
|
|
|
|
void loadQuestMarkerModels(); // Now loads BLP textures
|
|
|
|
|
void updateQuestMarkers(); // Updates billboard positions
|
2026-03-07 13:44:09 -08:00
|
|
|
|
|
|
|
|
// Background world preloader — warms AssetManager file cache for the
|
|
|
|
|
// expected world before the user clicks Enter World.
|
|
|
|
|
struct WorldPreload {
|
|
|
|
|
uint32_t mapId = 0;
|
|
|
|
|
std::string mapName;
|
|
|
|
|
int centerTileX = 0;
|
|
|
|
|
int centerTileY = 0;
|
|
|
|
|
std::atomic<bool> cancel{false};
|
|
|
|
|
std::vector<std::thread> workers;
|
|
|
|
|
};
|
|
|
|
|
std::unique_ptr<WorldPreload> worldPreload_;
|
|
|
|
|
void startWorldPreload(uint32_t mapId, const std::string& mapName, float serverX, float serverY);
|
|
|
|
|
void cancelWorldPreload();
|
|
|
|
|
void saveLastWorldInfo(uint32_t mapId, const std::string& mapName, float serverX, float serverY);
|
|
|
|
|
struct LastWorldInfo { uint32_t mapId = 0; std::string mapName; float x = 0, y = 0; bool valid = false; };
|
|
|
|
|
LastWorldInfo loadLastWorldInfo() const;
|
2026-02-02 12:24:50 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace core
|
|
|
|
|
} // namespace wowee
|