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

Function GetReturnStruct

extensions/dhooks/vhook.cpp:405–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403}
404
405HookReturnStruct *GetReturnStruct(DHooksCallback *dg)
406{
407 HookReturnStruct *res = new HookReturnStruct();
408 res->isChanged = false;
409 res->type = dg->returnType;
410 res->orgResult = NULL;
411 res->newResult = NULL;
412
413 if(g_SHPtr->GetOrigRet() && dg->post)
414 {
415 switch(dg->returnType)
416 {
417 case ReturnType_String:
418 res->orgResult = malloc(sizeof(string_t));
419 res->newResult = malloc(sizeof(string_t));
420 *(string_t *)res->orgResult = META_RESULT_ORIG_RET(string_t);
421 break;
422 case ReturnType_Int:
423 res->orgResult = malloc(sizeof(int));
424 res->newResult = malloc(sizeof(int));
425 *(int *)res->orgResult = META_RESULT_ORIG_RET(int);
426 break;
427 case ReturnType_Bool:
428 res->orgResult = malloc(sizeof(bool));
429 res->newResult = malloc(sizeof(bool));
430 *(bool *)res->orgResult = META_RESULT_ORIG_RET(bool);
431 break;
432 case ReturnType_Float:
433 res->orgResult = malloc(sizeof(float));
434 res->newResult = malloc(sizeof(float));
435 *(float *)res->orgResult = META_RESULT_ORIG_RET(float);
436 break;
437 case ReturnType_Vector:
438 {
439 res->orgResult = malloc(sizeof(SDKVector));
440 res->newResult = malloc(sizeof(SDKVector));
441 SDKVector vec = META_RESULT_ORIG_RET(SDKVector);
442 *(SDKVector *)res->orgResult = vec;
443 break;
444 }
445 default:
446 res->orgResult = META_RESULT_ORIG_RET(void *);
447 break;
448 }
449 }
450 else
451 {
452 switch(dg->returnType)
453 {
454 case ReturnType_String:
455 res->orgResult = malloc(sizeof(string_t));
456 res->newResult = malloc(sizeof(string_t));
457 *(string_t *)res->orgResult = NULL_STRING;
458 break;
459 case ReturnType_Vector:
460 res->orgResult = malloc(sizeof(SDKVector));
461 res->newResult = malloc(sizeof(SDKVector));
462 *(SDKVector *)res->orgResult = SDKVector();

Callers 2

vhook.cppFile · 0.85
Callback_stringtFunction · 0.85

Calls 1

SDKVectorClass · 0.85

Tested by

no test coverage detected