| 437 | } |
| 438 | |
| 439 | static cell_t smn_ReadPackFloatArray(IPluginContext *pContext, const cell_t *params) |
| 440 | { |
| 441 | HandleError herr; |
| 442 | HandleSecurity sec; |
| 443 | sec.pOwner = pContext->GetIdentity(); |
| 444 | sec.pIdentity = g_pCoreIdent; |
| 445 | |
| 446 | Handle_t hndl = static_cast<Handle_t>(params[1]); |
| 447 | CDataPack *pDataPack = nullptr; |
| 448 | if ((herr = handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack)) |
| 449 | != HandleError_None) |
| 450 | { |
| 451 | pContext->ReportError("Invalid data pack handle %x (error %d).", hndl, herr); |
| 452 | return 0; |
| 453 | } |
| 454 | |
| 455 | if (!pDataPack->IsReadable()) |
| 456 | { |
| 457 | pContext->ReportError("Data pack operation is out of bounds."); |
| 458 | return 0; |
| 459 | } |
| 460 | |
| 461 | if (pDataPack->GetCurrentType() != CDataPackType::FloatArray) |
| 462 | { |
| 463 | pContext->ReportError("Invalid data pack type (got %d / expected %d).", pDataPack->GetCurrentType(), CDataPackType::FloatArray); |
| 464 | return 0; |
| 465 | } |
| 466 | |
| 467 | cell_t packCount = 0; |
| 468 | cell_t *pData = pDataPack->ReadFloatArray(&packCount); |
| 469 | if(pData == nullptr || packCount == 0) |
| 470 | { |
| 471 | pContext->ReportError("Invalid data pack operation: current position isn't an array!"); |
| 472 | return 0; |
| 473 | } |
| 474 | |
| 475 | cell_t count = params[3]; |
| 476 | if(packCount > count) |
| 477 | { |
| 478 | pContext->ReportError("Input buffer too small (needed %d, got %d).", packCount, count); |
| 479 | return 0; |
| 480 | } |
| 481 | |
| 482 | cell_t *pArray; |
| 483 | pContext->LocalToPhysAddr(params[2], &pArray); |
| 484 | |
| 485 | memcpy(pArray, pData, sizeof(cell_t) * count); |
| 486 | |
| 487 | return 1; |
| 488 | } |
| 489 | |
| 490 | static cell_t smn_ResetPack(IPluginContext *pContext, const cell_t *params) |
| 491 | { |
nothing calls this directly
no test coverage detected