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

Function smn_PbReadVector

core/smn_protobuf.cpp:262–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260}
261
262static cell_t smn_PbReadVector(IPluginContext *pCtx, const cell_t *params)
263{
264 GET_MSG_FROM_HANDLE_OR_ERR();
265 GET_FIELD_NAME_OR_ERR();
266
267 cell_t *out;
268 pCtx->LocalToPhysAddr(params[3], &out);
269
270 Vector vec;
271 int index = params[0] >= 4 ? params[4] : -1;
272 if (index < 0)
273 {
274 if (!msg->GetVector(strField, &vec))
275 {
276 return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
277 }
278 }
279 else
280 {
281 if (!msg->GetRepeatedVector(strField, index, &vec))
282 {
283 return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, index, msg->GetProtobufMessage()->GetTypeName().c_str());
284 }
285 }
286
287 out[0] = sp_ftoc(vec.x);
288 out[1] = sp_ftoc(vec.y);
289 out[2] = sp_ftoc(vec.z);
290
291 return 1;
292}
293
294static cell_t smn_PbReadVector2D(IPluginContext *pCtx, const cell_t *params)
295{

Callers

nothing calls this directly

Calls 4

GetProtobufMessageMethod · 0.80
GetRepeatedVectorMethod · 0.80
GetVectorMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected