| 314 | } |
| 315 | |
| 316 | DataStatus DecodeValveParam(IPluginContext *pContext, |
| 317 | cell_t param, |
| 318 | const ValveCall *pCall, |
| 319 | const ValvePassInfo *data, |
| 320 | void *_buffer) |
| 321 | { |
| 322 | void *buffer = (unsigned char *)_buffer + data->offset; |
| 323 | switch (data->vtype) |
| 324 | { |
| 325 | case Valve_Vector: |
| 326 | { |
| 327 | cell_t *addr; |
| 328 | pContext->LocalToPhysAddr(param, &addr); |
| 329 | |
| 330 | unsigned char *mem = (unsigned char *)buffer; |
| 331 | if (data->type == PassType_Basic) |
| 332 | { |
| 333 | /* Store the object in the next N bytes, and store |
| 334 | * a pointer to that object right beforehand. |
| 335 | */ |
| 336 | Vector **realPtr = (Vector **)buffer; |
| 337 | |
| 338 | if (addr == pContext->GetNullRef(SP_NULL_VECTOR)) |
| 339 | { |
| 340 | if (data->decflags & VDECODE_FLAG_ALLOWNULL) |
| 341 | { |
| 342 | *realPtr = NULL; |
| 343 | return Data_Okay; |
| 344 | } else { |
| 345 | pContext->ThrowNativeError("NULL not allowed"); |
| 346 | return Data_Fail; |
| 347 | } |
| 348 | } else { |
| 349 | mem = (unsigned char *)_buffer + pCall->stackEnd + data->obj_offset; |
| 350 | *realPtr = (Vector *)mem; |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | /* Use placement new to initialize the object cleanly |
| 355 | * This has no destructor so we don't need to do |
| 356 | * DestroyValveParam() or something :] |
| 357 | */ |
| 358 | Vector *v = new (mem) Vector( |
| 359 | sp_ctof(addr[0]), |
| 360 | sp_ctof(addr[1]), |
| 361 | sp_ctof(addr[2])); |
| 362 | |
| 363 | return Data_Okay; |
| 364 | } |
| 365 | case Valve_QAngle: |
| 366 | { |
| 367 | cell_t *addr; |
| 368 | int err; |
| 369 | err = pContext->LocalToPhysAddr(param, &addr); |
| 370 | |
| 371 | unsigned char *mem = (unsigned char *)buffer; |
| 372 | if (data->type == PassType_Basic) |
| 373 | { |
no test coverage detected