What this quest function does
pc.give_and_equip_item(vnum) creates an item, tries to equip it and falls back to this branch's AutoGiveItem(LPITEM). It does not grant multiple items or replace equipment rules. Call it only from trusted, server-controlled quest paths; it is not a player command.

M2City r1 corrections
The supplied native callback fell off an int-returning Lua function without returning a result count. It now returns 0 on every path. The character is checked before item creation, avoiding an unowned allocation when no current character exists. The VNUM must be an integral value from 1 to 4294967295 before conversion to DWORD; invalid, fractional, NaN and infinite inputs are rejected.

Integrating into a private server
Merge the function into questlua_pc.cpp in the existing quest namespace. Register give_and_equip_item before the null terminator in pc_functions; add pc.give_and_equip_item to quest_functions if your qc requires that allowlist. Check DWORD width, CreateItem ownership, EquipItem restrictions and AutoGiveItem(LPITEM) ownership in your actual branch. The latter may drop items when inventory is full; this patch does not silently replace that policy.
In staging, exercise invalid and valid VNUMs, incompatible class/level equipment, occupied equipment, full inventory and repeated quest calls. Keep the reward condition and once-only quest flag in the quest that invokes it.

Validation
The single nonempty supplied source fragment was reviewed. The revised function compiled with clang++ C++11 and return-type warnings as errors, then passed fake-engine tests for absent character, invalid inputs, failed creation, equip success and fallback. No real Lua state, qc build, game binary or inventory transaction was exercised. The official Lua reference explains why the C return value counts results; it is not a compatibility certification for this archive.

Editorial resource — M2City
Version: Legacy integration fragments; exact fork unspecified; reviewed 2026-11-04; M2City r1
Rights: Public redistribution explicitly confirmed by supplying owner. Preserve creator notices; no blanket open-source licence granted.
Validation: Compiled exact reviewed function with existing dedicated clang++ C++11 and passed fake-engine assertions. Not a complete game/Lua build.
Source: Lua 5.1 manual for callback return protocol; creator attribution from supplied archive
SHA-256: 4463a7c55a0162b14a7f4d57ab48e11fcf1c82a608ac1dfd3f1ef7c7fbf5e61c