Skip to content

Mod Porting Guide

mittorn edited this page Nov 8, 2015 · 21 revisions

Server porting

Original valve's server code was compatible with linux and gcc 2.x Never gcc versions made restriction, that breaks build. Now, to make it build with gcc 4.x, you need do folowwing:

  • 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

Porting

First, remove all files and headers, that uses vgui (contains "vgui" in file name). After that, try to build it and remove vgui includes. Remove all gViewPort usings. Redefine all DLLEXPORT defines as empty field. Fix CAPS filenames in includes. Add ctype.h where it is need (tolower, isspace functions) Add string.h where it is need