diff --git a/src/game/client/entity.cpp b/src/game/client/entity.cpp index 31fc8b2fe..80f3f1b44 100644 --- a/src/game/client/entity.cpp +++ b/src/game/client/entity.cpp @@ -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)); diff --git a/src/game/client/ms/clplayer.cpp b/src/game/client/ms/clplayer.cpp index 99e1cbc7b..1fcabb579 100644 --- a/src/game/client/ms/clplayer.cpp +++ b/src/game/client/ms/clplayer.cpp @@ -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; @@ -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(); diff --git a/src/game/client/ui/ms/vgui_quickslot.h b/src/game/client/ui/ms/vgui_quickslot.h index b1ab31a40..fedd25c79 100644 --- a/src/game/client/ui/ms/vgui_quickslot.h +++ b/src/game/client/ui/ms/vgui_quickslot.h @@ -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) diff --git a/src/game/server/player/playershared.cpp b/src/game/server/player/playershared.cpp index e4cb9d340..e00f13a5c 100644 --- a/src/game/server/player/playershared.cpp +++ b/src/game/server/player/playershared.cpp @@ -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 @@ -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)) diff --git a/src/game/shared/ms/script.cpp b/src/game/shared/ms/script.cpp index ca5f4b30f..573f76169 100644 --- a/src/game/shared/ms/script.cpp +++ b/src/game/shared/ms/script.cpp @@ -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++) diff --git a/src/game/shared/ms/scriptcmds.cpp b/src/game/shared/ms/scriptcmds.cpp index d75c38163..9f6d655f7 100644 --- a/src/game/shared/ms/scriptcmds.cpp +++ b/src/game/shared/ms/scriptcmds.cpp @@ -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" ) {