Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/game/client/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1267,18 +1267,18 @@ void CScript::CLScriptedEffect(msstringlist &Params)
NewLight.color.g = Color.y;
NewLight.color.b = Color.z;
NewLight.die = gEngfuncs.GetClientTime() + atof(Params[NextParm++]);
if( NextParm >= Params.size())

if (NextParm < Params.size()) // optional flags param present
{
msstring &Flags = Params[NextParm++];
msstring& Flags = Params[NextParm++];
if (Flags.contains("entity"))
EntityLight = true;
if (Flags.contains("dark"))
NewLight.dark = true;
}

dlight_t *pLight = Params[1] == "new" ? (EntityLight ? gEngfuncs.pEfxAPI->CL_AllocElight(0) : gEngfuncs.pEfxAPI->CL_AllocDlight(0)) : (dlight_t *)atoi(Params[1]);
dlight_t* pLight = Params[1] == "new" ? (EntityLight ? gEngfuncs.pEfxAPI->CL_AllocElight(0) : gEngfuncs.pEfxAPI->CL_AllocDlight(0)) : (dlight_t*)atoi(Params[1]);

//AUG2013_19 - Thothie - extended conditional to encase m_gLastLightID line for saftey
if (pLight)
{
memcpy(pLight, &NewLight, sizeof(dlight_t));
Expand Down
6 changes: 3 additions & 3 deletions src/game/client/ms/clplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ int __MsgFunc_Item(const char* pszName, int iSize, void* pbuf)
//setviewmodelprop edits APR2008a MIB
{
msstring Mode = READ_STRING();
int iHand = READ_SHORT();
ulong lID = READ_LONG();
int iParam1;
float fParam1;
msstring sParam1;
Expand All @@ -990,10 +990,10 @@ int __MsgFunc_Item(const char* pszName, int iSize, void* pbuf)
iParam1 = READ_BYTE();
}

CGenericItem* pItem = player.Hand(iHand);
CGenericItem* pItem = MSUtil_GetItemByID(lID);
if (pItem)
{
if (Mode == "submodel")
if (Mode == "submodel" || Mode == "submodelbody")
{
pItem->m_ViewModelPart = iParam1;
pItem->m_ViewModelSubmodel = READ_BYTE();
Expand Down
32 changes: 32 additions & 0 deletions src/game/client/ui/ms/vgui_quickslot.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,42 @@ class VGUI_QuickSlot : public Panel, public IHUD
if (!QuickSlot.Active)
return;

if (QuickSlot.Type == QS_ITEM)
{
CGenericItem *pItem = player.FindItem(QuickSlot.ID);
CGenericItem *pSpare = (pItem && pItem->m_Location == ITEMPOS_HANDS) ? FindSpare(pItem) : NULL;
if (pSpare)
{
quickslot_t SpareSlot = QuickSlot;
SpareSlot.ID = pSpare->m_iId;
ConfirmItem(SpareSlot);
return;
}
}

ConfirmItem(QuickSlot);
}
}

CGenericItem *FindSpare(CGenericItem *pItem)
{
for (unsigned int i = 0; i < player.Gear.size(); i++)
{
CGenericItem *pPack = player.Gear[i];
if (pPack->m_Location == ITEMPOS_HANDS)
continue;

for (unsigned int n = 0; n < pPack->Container_ItemCount(); n++)
{
CGenericItem *pCopy = pPack->Container_GetItem(n);
if (pCopy && pCopy != pItem && !strcmp(pCopy->m_Name, pItem->m_Name))
return pCopy;
}
}

return NULL;
}

void AssignSlot(int Slot)
{
if (Slot < 0 || Slot >= MAX_QUICKSLOTS)
Expand Down
21 changes: 20 additions & 1 deletion src/game/server/player/playershared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,16 @@ bool CBasePlayer::AddItem(CGenericItem* pItem, bool ToHand, bool CheckWeight, in
return false;
}

static bool IsHandSwapWeapon(CGenericItem* pItem)
{
const char* pszWeapons[] = {"swords_", "axes_", "blunt_", "smallarms_", "polearms_", "bows_"};
for (unsigned int i = 0; i < sizeof(pszWeapons) / sizeof(pszWeapons[0]); i++)
if (!strncmp(pItem->m_Name, pszWeapons[i], strlen(pszWeapons[i])))
return true;

return false;
}

//Find a hand for an Item
//Returns:
//0 or 1 Item should be held in this hand
Expand Down Expand Up @@ -424,7 +434,16 @@ int CBasePlayer::NewItemHand(CGenericItem* pItem, bool CheckWeight, bool bVerbos
return !pItem->m_PrefHand; //Can hold item, but in the non-preferred hand
else
{
if (FreeHands) //Try to free the desired hand
#ifdef VALVE_DLL
if (FreeHands && IsHandSwapWeapon(pItem))
{
for (unsigned int i = 0; i < MAX_PLAYER_HANDS; i++)
if (Hand(i) && Hand(i)->m_PrefHand != BOTH_HANDS && IsHandSwapWeapon(Hand(i)) && strcmp(Hand(i)->m_Name, pItem->m_Name))
Hand(i)->PutAway(false);
Success = !HoldingTwoHandedItem && (!Hand(LEFT_HAND) || !Hand(RIGHT_HAND));
}
#endif
if (FreeHands && !Success) //Try to free the desired hand
{
int PrefHand = (pItem->m_PrefHand < ANY_HAND) ? pItem->m_PrefHand : m_PrefHand, OtherHand = !PrefHand;
if (!Hand(PrefHand) || Hand(PrefHand)->PutAway(false))
Expand Down
2 changes: 1 addition & 1 deletion src/game/shared/ms/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ const char* CScript::GetConst(const char* Text)
return ReturnString;
}
else
MS_ERROR("%s: Script: %s, \"%s\" - Mismatched Parenthesis!", m.ScriptFile.c_str(), Text);
MS_ERROR("%s: Script: %s, - Mismatched Parenthesis!", m.ScriptFile.c_str());
}
else
for (unsigned int i = 0; i < m_Constants.size(); i++)
Expand Down
2 changes: 1 addition & 1 deletion src/game/shared/ms/scriptcmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6689,7 +6689,7 @@ bool CScript::ScriptCmd_SetViewModelProp(SCRIPT_EVENT &Event, scriptcmd_t &Cmd,
MESSAGE_BEGIN( MSG_ONE, g_netmsg[NETMSG_ITEM], NULL, pPlayer->pev );
WRITE_BYTE( 7 );
WRITE_STRING( Params[1].c_str() );
WRITE_SHORT( pItem->m_Hand );
WRITE_LONG( pItem->m_iId );

if( Params[1] == "model" )
{
Expand Down
Loading