Skip to content

Commit

Permalink
Few changes:
Browse files Browse the repository at this point in the history
- Fixed fixed-size array syntax error in tf2utils.inc
- Fixed few warnings in cwx.sp
- Moved IsEmpty() check in GetLoadoutItem so if we no longer equip a custom weapon, it equips our loadout's instead.
  • Loading branch information
CppHorse committed Apr 18, 2023
1 parent 311a08a commit 9f73dd5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions scripting/cwx.sp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ Action OnPlayerLoadoutUpdated(UserMsg msg_id, BfRead msg, const int[] players,
int playersNum, bool reliable, bool init) {
int client = msg.ReadByte();
s_LastUpdatedClient = GetClientSerial(client);
return Plugin_Continue;
}

/**
Expand Down Expand Up @@ -431,18 +432,17 @@ MRESReturn OnGetLoadoutItemPost(int client, Handle hReturn, Handle hParams) {
if (loadoutSlot < 0 || loadoutSlot >= NUM_ITEMS) {
return MRES_Ignored;
}

if (g_CurrentLoadout[client][playerClass][loadoutSlot].IsEmpty()) {
// we don't have nor want a custom item; let the game process it
return MRES_Ignored;
}

// the loadout entity we keep track of isn't valid, so we may need to make one
// we expect to have to equip something new at this point
int storedItem = g_CurrentLoadout[client][playerClass][loadoutSlot].entity;
if (!IsValidEntity(storedItem) || GetEntityFlags(storedItem) & FL_KILLME
|| !HasEntProp(storedItem, Prop_Send, "m_Item")) {
// the loadout entity we keep track of isn't valid, so we may need to make one
// we expect to have to equip something new at this point

if (g_CurrentLoadout[client][playerClass][loadoutSlot].IsEmpty()) {
// we don't have nor want a custom item; let the game process it
return MRES_Ignored;
}

/**
* We have a custom item we'd like to spawn in; don't return a loadout item, otherwise
* we may equip / unequip a user's inventory weapon that has side effects
Expand Down Expand Up @@ -546,6 +546,7 @@ public Action OnClientCommandKeyValues(int client, KeyValues kv) {
if (StrEqual(cmd, "MVM_Respec")) {
g_bForceReequipItems[client] = true;
}
return Plugin_Continue;
}

public void OnClientCommandKeyValues_Post(int client, KeyValues kv) {
Expand Down Expand Up @@ -632,6 +633,7 @@ int Native_RemovePlayerLoadoutItem(Handle plugin, int argc) {
int flags = GetNativeCell(4);

UnsetClientCustomLoadoutItem(client, playerClass, itemSlot, flags);
return true;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion third_party/vendored/tf2utils.inc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ native void TF2Util_UpdatePlayerSpeed(int client, bool immediate = false);
* the position is in an active spawn room. Has no effect if no
* entity is provided.
*/
native bool TF2Util_IsPointInRespawnRoom(const float[3] position,
native bool TF2Util_IsPointInRespawnRoom(const float position[3],
int entity = INVALID_ENT_REFERENCE, bool bRestrictToSameTeam = false);

// compile-time compatibility shim for tf2wearables natives
Expand Down

0 comments on commit 9f73dd5

Please sign in to comment.