diff --git a/src/Components/Loader.cpp b/src/Components/Loader.cpp index fc09bb18..4b50eadc 100644 --- a/src/Components/Loader.cpp +++ b/src/Components/Loader.cpp @@ -12,6 +12,7 @@ #include "Modules/Changelog.hpp" #include "Modules/Chat.hpp" #include "Modules/ClanTags.hpp" +#include "Modules/Weapon.hpp" // Load before for G_ModelIndex #include "Modules/ClientCommand.hpp" #include "Modules/ConnectProtocol.hpp" #include "Modules/Console.hpp" @@ -62,7 +63,6 @@ #include "Modules/VisionFile.hpp" #include "Modules/Voice.hpp" #include "Modules/Vote.hpp" -#include "Modules/Weapon.hpp" #include "Modules/Window.hpp" #include "Modules/BotLib/lPrecomp.hpp" diff --git a/src/Components/Modules/AssetInterfaces/ITracerDef.cpp b/src/Components/Modules/AssetInterfaces/ITracerDef.cpp index 98962180..7500b23b 100644 --- a/src/Components/Modules/AssetInterfaces/ITracerDef.cpp +++ b/src/Components/Modules/AssetInterfaces/ITracerDef.cpp @@ -3,9 +3,9 @@ namespace Assets { - void ITracerDef::load(Game::XAssetHeader* /*header*/, const std::string& /*name*/, Components::ZoneBuilder::Zone* /*builder*/) + void ITracerDef::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) { - // don't load from filesystem right now + header->tracerDef = builder->getIW4OfApi()->read(Game::XAssetType::ASSET_TYPE_TRACER, name); } void ITracerDef::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) diff --git a/src/Components/Modules/AssetInterfaces/IWeapon.cpp b/src/Components/Modules/AssetInterfaces/IWeapon.cpp index e3b24bc1..a192662b 100644 --- a/src/Components/Modules/AssetInterfaces/IWeapon.cpp +++ b/src/Components/Modules/AssetInterfaces/IWeapon.cpp @@ -129,7 +129,10 @@ namespace Assets if (asset->weapDef->projIgnitionEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->projIgnitionEffect); if (asset->weapDef->turretOverheatEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->turretOverheatEffect); -#define LoadWeapSound(sound) if (asset->weapDef->##sound##) builder->loadAsset(Game::XAssetType::ASSET_TYPE_SOUND, asset->weapDef->##sound##) + + + // They are not subassets, because they don't get loaded automatically +#define LoadWeapSound(sound) if (asset->weapDef->##sound##) builder->loadAsset(Game::XAssetType::ASSET_TYPE_SOUND, asset->weapDef->##sound##, false) LoadWeapSound(pickupSound); LoadWeapSound(pickupSoundPlayer); diff --git a/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp b/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp index e8b9860c..0a9bd565 100644 --- a/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp +++ b/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp @@ -14,7 +14,7 @@ namespace Assets if (asset->names) { - for (char i = 0; i < asset->boneCount[Game::PART_TYPE_ALL]; ++i) + for (unsigned char i = 0; i < asset->boneCount[Game::PART_TYPE_ALL]; ++i) { builder->addScriptString(asset->names[i]); } @@ -22,7 +22,7 @@ namespace Assets if (asset->notify) { - for (char i = 0; i < asset->notifyCount; ++i) + for (unsigned char i = 0; i < asset->notifyCount; ++i) { builder->addScriptString(asset->notify[i].name); } @@ -165,7 +165,7 @@ namespace Assets unsigned short* destTagnames = buffer->dest(); buffer->saveArray(asset->names, asset->boneCount[Game::PART_TYPE_ALL]); - for (char i = 0; i < asset->boneCount[Game::PART_TYPE_ALL]; ++i) + for (unsigned char i = 0; i < asset->boneCount[Game::PART_TYPE_ALL]; ++i) { builder->mapScriptString(destTagnames[i]); } @@ -181,7 +181,7 @@ namespace Assets Game::XAnimNotifyInfo* destNotetracks = buffer->dest(); buffer->saveArray(asset->notify, asset->notifyCount); - for (char i = 0; i < asset->notifyCount; ++i) + for (unsigned char i = 0; i < asset->notifyCount; ++i) { builder->mapScriptString(destNotetracks[i].name); } diff --git a/src/Components/Modules/ClientCommand.cpp b/src/Components/Modules/ClientCommand.cpp index f80f9eb8..f7c8f5ca 100644 --- a/src/Components/Modules/ClientCommand.cpp +++ b/src/Components/Modules/ClientCommand.cpp @@ -1,6 +1,8 @@ #include #include "ClientCommand.hpp" +#include "Weapon.hpp" + #include "GSC/Script.hpp" using namespace Utils::String; @@ -382,7 +384,14 @@ namespace Components Game::XModel* model = nullptr; if (ent->model) { - model = Game::G_GetModel(ent->model); + if (Components::Weapon::GModelIndexHasBeenReallocated) + { + model = Components::Weapon::G_ModelIndexReallocated[ent->model]; + } + else + { + model = Game::G_GetModel(ent->model); + } } Game::vec3_t point, angles; diff --git a/src/Components/Modules/Weapon.cpp b/src/Components/Modules/Weapon.cpp index b9eb33ab..5f3fd9f0 100644 --- a/src/Components/Modules/Weapon.cpp +++ b/src/Components/Modules/Weapon.cpp @@ -7,6 +7,7 @@ namespace Components { const Game::dvar_t* Weapon::BGWeaponOffHandFix; Game::XModel* Weapon::G_ModelIndexReallocated[G_MODELINDEX_LIMIT]; + bool Weapon::GModelIndexHasBeenReallocated; Game::WeaponCompleteDef* Weapon::LoadWeaponCompleteDef(const char* name) { @@ -447,7 +448,8 @@ namespace Components Utils::Hook::Set(0x5FC762 + 3, G_ModelIndexReallocated); Utils::Hook::Set(0x5FC7BE + 3, G_ModelIndexReallocated); Utils::Hook::Set(0x44F256 + 2, G_MODELINDEX_LIMIT); - + + GModelIndexHasBeenReallocated = true; } void* Weapon::LoadNoneWeaponHook() diff --git a/src/Components/Modules/Weapon.hpp b/src/Components/Modules/Weapon.hpp index 4da87eb2..cc92d59d 100644 --- a/src/Components/Modules/Weapon.hpp +++ b/src/Components/Modules/Weapon.hpp @@ -6,8 +6,6 @@ #define MAX_CONFIGSTRINGS (4139 - 1200 + WEAPON_LIMIT) #define G_MODELINDEX_LIMIT (526 + WEAPON_LIMIT - 1200) -#define G_MODELINDEX_HAS_BEEN_REALLOCATED - namespace Components { class Weapon : public Component @@ -16,6 +14,8 @@ namespace Components Weapon(); static Game::XModel* G_ModelIndexReallocated[G_MODELINDEX_LIMIT]; + static bool GModelIndexHasBeenReallocated; + private: static const Game::dvar_t* BGWeaponOffHandFix; diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 4b72f36d..21842c63 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -1044,8 +1044,8 @@ namespace Game unsigned __int16 randomDataIntCount; unsigned __int16 numframes; char flags; - char boneCount[10]; - char notifyCount; + unsigned char boneCount[10]; + unsigned char notifyCount; char assetType; bool isDefault; unsigned int randomDataShortCount;