builtin_ftoe_etof.txt

来自「quake1 dos源代码最新版本」· 文本 代码 · 共 62 行

TXT
62
字号
================================================================
Title         : Tutorial: Builtin functions etof and ftoe
Date          : 2001-10-05
Filename      : BUILTIN_FTOE_ETOF.TXT
Author        : Matthias "Maddes" Buecher
Email Address : maddes@go.to
Homepage      : Quake Info Pool
                http://www.quake-info-pool.net/
                Quake Standards Group (short QSG)
                http://www.quakesrc.org/
Complexity    : Low
================================================================

The builtin functions are called "etof" and "ftoe". "etof" returns the number of
the edict/entity, while "ftoe" returns the edict/entity of a number.

These functions were added to the QSG standard by using the Enhanced BuiltIn 
Function System (EBFS) with the numbers #108 and #109. If you want to add these 
functions to your own engine, you should add the EBFS before.


In PR_CMDS.C add the following code anywhere before the builtin variables...

// 2001-09-25 New BuiltIn Function: etof() by Maddes  start
/*
=================
PF_etof

float etof (entity)
=================
*/
void PF_etof (void)
{
	G_FLOAT(OFS_RETURN) = G_EDICTNUM(OFS_PARM0);
}
// 2001-09-25 New BuiltIn Function: etof() by Maddes  end

// 2001-09-25 New BuiltIn Function: ftoe() by Maddes  start
/*
=================
PF_ftoe

entity ftoe (float)
=================
*/
void PF_ftoe (void)
{
	edict_t		*e;

	e = EDICT_NUM(G_FLOAT(OFS_PARM0));
	RETURN_EDICT(e);
}
// 2001-09-25 New BuiltIn Function: ftoe() by Maddes  end

   ... and to the EBFS data array add ...

	{ 108, "etof", PF_etof },	// 2001-09-25 New BuiltIn Function: etof() by Maddes

	{ 109, "ftoe", PF_ftoe },	// 2001-09-25 New BuiltIn Function: ftoe() by Maddes

Done.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?