Skip to content

Commit

Permalink
Merge branch 'dev' into globalwar
Browse files Browse the repository at this point in the history
  • Loading branch information
ChugunovRoman committed Dec 12, 2024
2 parents 1eed292 + 4312254 commit 5e06449
Show file tree
Hide file tree
Showing 31 changed files with 91 additions and 36 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: FreeBSD, os: freebsd, os-version: '14.1', arch: x86_64,
- { name: FreeBSD, os: freebsd, os-version: '14.2', arch: x86_64,
install-cmd: "sudo pkg update && sudo pkg install -y cmake sdl2 lzo2 jpeg-turbo openal-soft libogg libtheora libvorbis"
}
- { name: OpenBSD, os: openbsd, os-version: '7.5', arch: x86_64,
- { name: OpenBSD, os: openbsd, os-version: '7.6', arch: x86_64,
install-cmd: "sudo pkg_add cmake SDL2 lzo2 jpeg openal libogg libtheora libvorbis",
}
- { name: NetBSD, os: netbsd, os-version: '10.0', arch: x86_64,
Expand All @@ -196,7 +196,7 @@ jobs:
submodules: recursive

- name: Setup ${{ matrix.platform.name }} and packages
uses: cross-platform-actions/action@v0.25.0
uses: cross-platform-actions/action@v0.26.0
with:
operating_system: ${{ matrix.platform.os }}
architecture: ${{ matrix.platform.arch }}
Expand All @@ -209,7 +209,7 @@ jobs:
run: ${{ matrix.platform.install-cmd }}

- name: Run CMake
uses: cross-platform-actions/action@v0.25.0
uses: cross-platform-actions/action@v0.26.0
with:
operating_system: ${{ matrix.platform.os }}
architecture: ${{ matrix.platform.arch }}
Expand All @@ -222,7 +222,7 @@ jobs:
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.Configuration }} -DCMAKE_UNITY_BUILD=ON

- name: Run CMake Build
uses: cross-platform-actions/action@v0.25.0
uses: cross-platform-actions/action@v0.26.0
with:
operating_system: ${{ matrix.platform.os }}
architecture: ${{ matrix.platform.arch }}
Expand Down
Binary file removed misc/media/OpenXRay Splash.500x268.psd
Binary file not shown.
Binary file removed misc/media/OpenXRay Splash.psd
Binary file not shown.
8 changes: 8 additions & 0 deletions res/gamedata/configs/openxray.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ allow_escape_sequences = false
; cop, cs, shoc or soc and unlock
; unlock is cop with disabled restrictions
game_mode = cop

; Always try to put item in the slot, SOC behaviour
; For the comparison, COP tries to do that only if item has default_to_ruck = false
default_to_slot = false

; SOC/CS slots ordering
; e.g. knife slot is 0 in SOC/CS and 1 in COP
minus_one_slot_ordering = false
Binary file removed sdk/libraries/ARM/libogg_static.lib
Binary file not shown.
Binary file removed sdk/libraries/ARM/libtheora_static.lib
Binary file not shown.
Binary file removed sdk/libraries/ARM/libvorbis_static.lib
Binary file not shown.
Binary file removed sdk/libraries/ARM/libvorbisfile.lib
Binary file not shown.
Binary file removed sdk/libraries/ARM/lzo.lib
Binary file not shown.
Binary file modified sdk/libraries/ARM64/libogg_static.lib
Binary file not shown.
Binary file modified sdk/libraries/ARM64/libtheora_static.lib
Binary file not shown.
Binary file modified sdk/libraries/ARM64/libvorbis_static.lib
Binary file not shown.
Binary file modified sdk/libraries/ARM64/libvorbisfile.lib
Binary file not shown.
Binary file modified sdk/libraries/ARM64/lzo.lib
Binary file not shown.
Binary file modified sdk/libraries/x64/libogg_static.lib
Binary file not shown.
Binary file modified sdk/libraries/x64/libtheora_static.lib
Binary file not shown.
Binary file modified sdk/libraries/x64/libvorbis_static.lib
Binary file not shown.
Binary file modified sdk/libraries/x64/libvorbisfile.lib
Binary file not shown.
Binary file modified sdk/libraries/x64/lzo.lib
Binary file not shown.
Binary file modified sdk/libraries/x86/libogg_static.lib
Binary file not shown.
Binary file modified sdk/libraries/x86/libtheora_static.lib
Binary file not shown.
Binary file modified sdk/libraries/x86/libvorbis_static.lib
Binary file not shown.
Binary file modified sdk/libraries/x86/libvorbisfile.lib
Binary file not shown.
Binary file modified sdk/libraries/x86/lzo.lib
Binary file not shown.
22 changes: 21 additions & 1 deletion src/Include/xrRender/FactoryPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,38 @@ class FactoryPtr

FactoryPtr& operator=(const FactoryPtr& _in)
{
m_pObject->Copy(*_in.m_pObject);
if (this != &_in)
m_pObject->Copy(*_in.m_pObject);
return *this;
}

FactoryPtr(FactoryPtr&& other) noexcept
: m_pObject(other.m_pObject)
{
other.m_pObject = nullptr;
}

FactoryPtr& operator=(FactoryPtr&& other) noexcept
{
if (this != &other)
{
DestroyObject();
m_pObject = other.m_pObject;
other.m_pObject = nullptr;
}
return *this;
}

T& operator*() const { return *m_pObject; }
T* operator->() const { return m_pObject; }
operator bool() const { return m_pObject; }
bool operator!() const { return m_pObject == nullptr; }

private:
void CreateObject();
void DestroyObject();
T const* get() const { return m_pObject; }

private:
T* m_pObject;
};
Expand Down
15 changes: 15 additions & 0 deletions src/xrCore/xr_resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ class resptr_base
T* prhs = rhs._get();
_set(prhs);
}
ICF void _set(resptr_base<T>&& rhs)
{
p_ = rhs.p_;
rhs.p_ = nullptr;
}
ICF T* _get() const { return p_; }
void _clear() { p_ = 0; }
};
Expand All @@ -106,13 +111,23 @@ class resptr_core : public C
C::p_ = rhs.p_;
C::_inc();
}
resptr_core(self&& rhs) noexcept
{
C::p_ = rhs.p_;
rhs.p_ = nullptr;
}
~resptr_core() { C::_dec(); }
// assignment
self& operator=(const self& rhs)
{
this->_set(rhs);
return (self&)*this;
}
self& operator=(self&& rhs) noexcept
{
this->_set(std::move(rhs));
return (self&)*this;
}

// accessors
T& operator*() const { return *C::p_; }
Expand Down
49 changes: 29 additions & 20 deletions src/xrGame/Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ int g_auto_ammo_unload = 0;

bool defaultSlotActiveness[] =
{
false, // no slot
true, // knife
true, // pistol
true, // automatic
Expand Down Expand Up @@ -232,33 +233,30 @@ void CInventory::Take(CGameObject* pObj, bool bNotActivate, bool strict_placemen

if (pIItem->CurrPlace() == eItemPlaceUndefined)
{
if (!pIItem->RuckDefault())
const bool slotFirst = pSettingsOpenXRay->read_if_exists<bool>("compatibility", "default_to_slot", ShadowOfChernobylMode);
const bool defaultToRuck = pIItem->RuckDefault();

if (slotFirst || !defaultToRuck)
{
if (CanPutInSlot(pIItem, pIItem->BaseSlot()))
{
result = Slot(pIItem->BaseSlot(), pIItem, bNotActivate, strict_placement);
VERIFY(result);
}
else if (CanPutInBelt(pIItem))
else if (!defaultToRuck && CanPutInBelt(pIItem))
{
result = Belt(pIItem, strict_placement);
VERIFY(result);
}
else
{
result = Ruck(pIItem, strict_placement);
VERIFY(result);
CWeaponMagazined* pWeapon = smart_cast<CWeaponMagazined*>(pIItem);
if (pWeapon && result && g_auto_ammo_unload)
{
pWeapon->UnloadMagazine();
}
}
}
else

if (!result)
{
result = Ruck(pIItem, strict_placement);
VERIFY(result);
CWeaponMagazined* pWeapon = smart_cast<CWeaponMagazined*>(pIItem);
if (pWeapon && result && !defaultToRuck && g_auto_ammo_unload)
{
pWeapon->UnloadMagazine();
}
}
}

Expand Down Expand Up @@ -665,10 +663,16 @@ void CInventory::Activate(u16 slot, bool bForce)
PIItem active_item = ActiveItem();
if (active_item && !bForce)
{
CHudItem* tempItem = active_item->cast_hud_item();
R_ASSERT2(tempItem, active_item->object().cNameSect().c_str());
if (CHudItem* tempItem = active_item->cast_hud_item())
tempItem->SendDeactivateItem();
else
{
#ifndef MASTER_GOLD
Msg("! Can't cast [%s] to CHudItem", active_item->object().cNameSect().c_str());
#endif
active_item->DeactivateItem();
}

tempItem->SendDeactivateItem();
#ifdef DEBUG
// Msg("--- Inventory owner [%s]: send deactivate item [%s]", m_pOwner->Name(), active_item->NameItem());
#endif // #ifdef DEBUG
Expand Down Expand Up @@ -861,7 +865,7 @@ void CInventory::Update()
{
CHudItem* hi = ActiveItem()->cast_hud_item();

if (!hi->IsHidden())
if (hi && !hi->IsHidden())
{
if (hi->GetState() == CHUDState::eIdle && hi->GetNextState() == CHUDState::eIdle)
hi->SendDeactivateItem();
Expand Down Expand Up @@ -893,8 +897,13 @@ void CInventory::Update()

m_iActiveSlot = GetNextActiveSlot();
}
if ((GetNextActiveSlot() != NO_ACTIVE_SLOT) && ActiveItem() && ActiveItem()->cast_hud_item()->IsHidden())
if (GetNextActiveSlot() != NO_ACTIVE_SLOT &&
ActiveItem() &&
ActiveItem()->cast_hud_item() &&
ActiveItem()->cast_hud_item()->IsHidden())
{
ActiveItem()->ActivateItem();
}
}
UpdateDropTasks();
}
Expand Down
11 changes: 5 additions & 6 deletions src/xrGame/inventory_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,15 @@ net_updateInvData* CInventoryItem::NetSync()

CInventoryItem::CInventoryItem()
{
m_net_updateData = NULL;
m_flags.set(Fbelt, FALSE);
m_flags.set(Fruck, TRUE);
m_flags.set(FRuckDefault, TRUE);
m_pInventory = NULL;

SetDropManual(FALSE);

m_flags.set(FCanTake, TRUE);
m_can_trade = TRUE;
m_flags.set(FCanTrade, m_can_trade);
m_flags.set(FUsingCondition, FALSE);
m_fCondition = 1.0f;

m_name = m_nameShort = m_tip = "";

Expand Down Expand Up @@ -112,8 +108,11 @@ void CInventoryItem::Load(LPCSTR section)
R_ASSERT(m_weight >= 0.f);

m_cost = pSettings->r_u32(section, "cost");
u32 sl = pSettings->read_if_exists<u32>(section, "slot", NO_ACTIVE_SLOT);
m_ItemCurrPlace.base_slot_id = (sl == u32(-1)) ? 0 : (sl + 1);

// Assets follow initial SOC system, where slots start from -1
u32 sl = pSettings->read_if_exists<u32>(section, "slot", NO_ACTIVE_SLOT - 1);
// Engine is following new system since COP: slots start from 0
m_ItemCurrPlace.base_slot_id = sl + 1;

string16 count{"0"};
CBolt* pBolt = smart_cast<CBolt*>(this);
Expand Down
8 changes: 4 additions & 4 deletions src/xrGame/inventory_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CInventoryItem : public CAttachableItem,
};

Flags16 m_flags;
BOOL m_can_trade;
bool m_can_trade{ true };

public:
CInventoryItem();
Expand Down Expand Up @@ -152,7 +152,7 @@ class CInventoryItem : public CAttachableItem,
void SetWeight(float w) { m_weight = w; }

public:
CInventory* m_pInventory;
CInventory* m_pInventory{};
shared_str m_section_id;
shared_str m_name;
shared_str m_nameShort;
Expand Down Expand Up @@ -194,7 +194,7 @@ class CInventoryItem : public CAttachableItem,
protected:
u32 m_cost;
float m_weight;
float m_fCondition;
float m_fCondition{ 1.0f };
shared_str m_Description;

protected:
Expand Down Expand Up @@ -228,7 +228,7 @@ class CInventoryItem : public CAttachableItem,
virtual void UpdateXForm();

protected:
net_updateInvData* m_net_updateData;
net_updateInvData* m_net_updateData{};
net_updateInvData* NetSync();
void CalculateInterpolationParams();

Expand Down
3 changes: 3 additions & 0 deletions src/xrGame/script_game_object_inventory_owner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,9 @@ CScriptGameObject* CScriptGameObject::item_in_slot(u32 slot_id) const
return (0);
}

if (pSettingsOpenXRay->read_if_exists<bool>("compatibility", "minus_one_slot_ordering", ShadowOfChernobylMode || ClearSkyMode))
++slot_id;

CInventoryItem* result = inventory_owner->inventory().ItemFromSlot((u16)slot_id);
return (result ? result->object().lua_game_object() : 0);
}
Expand Down
1 change: 1 addition & 0 deletions src/xrPhysics/xrPhysics.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<PreprocessorDefinitions>_USRDLL;XRPHYSICS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(xrExternals)ode/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FloatingPointModel Condition="'$(Platform)'=='x64'">Precise</FloatingPointModel>
<DisableSpecificWarnings Condition="'$(PlatformShortName)'=='x86'">4756;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down

0 comments on commit 5e06449

Please sign in to comment.