| 447 | } |
| 448 | |
| 449 | static cell_t smn_PbSetString(IPluginContext *pCtx, const cell_t *params) |
| 450 | { |
| 451 | GET_MSG_FROM_HANDLE_OR_ERR(); |
| 452 | GET_FIELD_NAME_OR_ERR(); |
| 453 | |
| 454 | char *strValue; |
| 455 | pCtx->LocalToString(params[3], &strValue); |
| 456 | |
| 457 | int index = params[0] >= 4 ? params[4] : -1; |
| 458 | if (index < 0) |
| 459 | { |
| 460 | if (!msg->SetString(strField, strValue)) |
| 461 | { |
| 462 | return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str()); |
| 463 | } |
| 464 | } |
| 465 | else |
| 466 | { |
| 467 | if (!msg->SetRepeatedString(strField, index, strValue)) |
| 468 | { |
| 469 | return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, index, msg->GetProtobufMessage()->GetTypeName().c_str()); |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | return 1; |
| 474 | } |
| 475 | |
| 476 | static cell_t smn_PbSetColor(IPluginContext *pCtx, const cell_t *params) |
| 477 | { |
nothing calls this directly
no test coverage detected