Skip to content

Mod Porting Guide

xDShot edited this page Nov 8, 2015 · 21 revisions

Server porting

Original valve's server code was compatible with linux and gcc 2.x. Newer gcc versions have restriction which breaks building. Now, to make it build with gcc 4.x, you need do following:

  • Go to cbase.h and redefine macrosses as following
#define SetThink( a ) m_pfnThink = static_cast <void (CBaseEntity::*)(void)> (&a)
#define SetTouch( a ) m_pfnTouch = static_cast <void (CBaseEntity::*)(CBaseEntity *)> (&a)
#define SetUse( a ) m_pfnUse = static_cast <void (CBaseEntity::*)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )> (&a)
#define SetBlocked( a ) m_pfnBlocked = static_cast <void (CBaseEntity::*)(CBaseEntity *)> (&a)
#define ResetThink( ) m_pfnThink = static_cast <void (CBaseEntity::*)(void)> (NULL)
#define ResetTouch( ) m_pfnTouch = static_cast <void (CBaseEntity::*)(CBaseEntity *)> (NULL)
#define ResetUse( ) m_pfnUse = static_cast <void (CBaseEntity::*)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )> (NULL)
#define ResetBlocked( ) m_pfnBlocked = static_cast <void (CBaseEntity::*)(CBaseEntity *)> (NULL)
...
#define SetMoveDone( a ) m_pfnCallWhenMoveDone = static_cast <void (CBaseToggle::*)(void)> (&a)
  • Replace all SetThink(NULL), SetTouch(NULL), setUse(NULL) and SetBlocked(NULL) by ResetThink(), ResetTouch(), ResetUse() and ResetBlocked()
  • Sometimes you may need to add #include <ctype.h> if functions tolower or isspace are missing

Client porting

VGUI library

Valve's client uses vgui library that is availiable only on x86 systems and has big amount of mistakes in headers. The best and simpliest way of porting is removing vgui dependency at all. Most singleplayer mods does not really use vgui it all. It used in multiplayer only to show score table and MOTD window