MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / smn_WritePackFunction

Function smn_WritePackFunction

core/logic/smn_datapacks.cpp:225–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225static cell_t smn_WritePackFunction(IPluginContext *pContext, const cell_t *params)
226{
227 Handle_t hndl = static_cast<Handle_t>(params[1]);
228 HandleError herr;
229 HandleSecurity sec;
230 CDataPack *pDataPack;
231
232 sec.pOwner = pContext->GetIdentity();
233 sec.pIdentity = g_pCoreIdent;
234
235 if ((herr = handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
236 != HandleError_None)
237 {
238 return pContext->ThrowNativeError("Invalid data pack handle %x (error %d).", hndl, herr);
239 }
240
241 bool insert = (params[0] >= 3) ? params[3] : false;
242 if (!insert)
243 {
244 pDataPack->RemoveItem();
245 }
246
247 cell_t funcid = params[2];
248 if (pContext->IsNullFunctionId(funcid))
249 {
250 pDataPack->PackFunction(0);
251 }
252 else if (funcid <= 0)
253 {
254 return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
255 }
256 else
257 {
258 pDataPack->PackFunction(funcid);
259 }
260
261 return 1;
262}
263
264static cell_t smn_ReadPackCell(IPluginContext *pContext, const cell_t *params)
265{

Callers

nothing calls this directly

Calls 4

PackFunctionMethod · 0.80
GetIdentityMethod · 0.45
ReadHandleMethod · 0.45
RemoveItemMethod · 0.45

Tested by

no test coverage detected