Raised This Month: $51 Target: $400
 12% 

How it's working? (engfunc)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krystek.
Member
Join Date: May 2022
Old 02-22-2023 , 04:28   How it's working? (engfunc)
Reply With Quote #1

How do these things work?

HTML Code:
engfunc(EngFunc_AllocString, "info_target")
HTML Code:
engfunc(EngFunc_CreateNamedEntity, iszInfoTarget)

And I encountered something like this

HTML Code:
engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
At first I thought I could replace it with
HTML Code:
create_entity(const szClassname[]);
But that's probably not the right usage


I am posting a snippet of code where it is used
HTML Code:
	static iszInfoTarget
	if( !iszInfoTarget ) {
		iszInfoTarget = engfunc(EngFunc_AllocString, "info_target")
	}

	new iEnt = engfunc(EngFunc_CreateNamedEntity, iszInfoTarget)
	if( iEnt > 0) {
		static iszClass = 0
		if( !iszClass ) {
			iszClass = engfunc(EngFunc_AllocString, PARACHUTE_CLASS)
		}

Last edited by Krystek.; 02-22-2023 at 04:29.
Krystek. is offline
AnimalMonster
Senior Member
Join Date: May 2020
Old 02-22-2023 , 16:25   Re: How it's working? (engfunc)
Reply With Quote #2

This, i think, is the code for allocating strings. Maybe it helps you or someone else to explain it.

PHP Code:
void *Hunk_AllocName(int size, const char *name)
{
    if (
size 0)
    {
        
Sys_Error("%s: bad size: %i"__func__size);
    }

    
int totalsize = ((size 15) & ~15) + sizeof(hunk_t);

    if (
hunk_size hunk_high_used hunk_low_used totalsize)
    {
        
Sys_Error("%s: failed on %i bytes"__func__totalsize);
    }

    
hunk_t *= (hunk_t *)(hunk_base hunk_low_used);

    
hunk_low_used += totalsize;
    
Cache_FreeLow(hunk_low_used);

    
Q_memset(h0totalsize);
    
h->size totalsize;
    
h->sentinel HUNK_SENTINEL;
    
Q_strncpy(h->namenameHUNK_NAME_LEN 1);
    
h->name[HUNK_NAME_LEN 1] = 0;

    return (
void *)(1);

AnimalMonster is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode