User:Psycommando/Macros reference

From Valve Developer Community
Jump to navigation Jump to search

Intro

Prototype for a complete list of macros links(in the wiki) and infos. All Macros are listed in different categories, and divided in groups.

Warning on macros

For those unfamiliar with macros, I must warn you that macros are EVIL. They are basically the equivalent of doing a search and replace at compile time, therefore never ever put an operation as a macro parameter!!! This page C++ Faq Lite describe most of the problem. Be sure to check evil# 1-2-3-4.


Data map

Declaration :

Definition :

Network

IMPLEMENT_NETWORKCLASS_ALIASED

  • Call : IMPLEMENT_NETWORKCLASS_ALIASED( className, dataTable )
  • Declaration : From ..\game\shared\predictable_entity.h
#define IMPLEMENT_NETWORKCLASS_ALIASED(className, dataTable)			\
	IMPLEMENT_CLIENTCLASS( C_##className, dataTable, C##className )
  • Description :
  • Example :

Misc

MDLCACHE_CRITICAL_SECTION

  • Call : MDLCACHE_CRITICAL_SECTION()
  • Description : This one is still an enigma. It create a critical section to avoid concurrent accesses to what seems to be a bunch of loaded source .mdl files, but why is it used when simply modifying or calling an entity's methods?(Answers on talk page are welcome)
  • Example : (From ..\src\game\server\gameinterface.cpp)
	// Call all entities' OnRestore handlers
	for ( int i = g_RestoredEntities.Count()-1; i >=0; --i )
	{
		CBaseEntity *pEntity = g_RestoredEntities[i].Get();
		if ( pEntity && !pEntity->IsDormant() )
		{
			MDLCACHE_CRITICAL_SECTION();
			pEntity->OnRestore();
		}
	}