View Single Post
  #4  
Old 01-19-2008, 02:52 AM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default Two files that go in "common"

Code:
common/default_Hooks.h
----------------------
#ifndef DEFAULT_RULES_H_
#define DEFAULT_RULES_H_

#include "../common/eq_packet_structs.h"

/** A hook can be a function pointer of any type. So we define it as void *.
 *  Hooks are cast to their actual function type when they are called.
 */
typedef void *Hook;

/** Macro used to check the compliance of hook functions with the definition of the hook.
 *  It ensures the hook function has the correct signature.
 *  It can be very useful to avoid mistakes, and when a hook signature changes.
 *  The compiler can then issue an error.
 *  If no signature check is done, a badly-defined hook function will probably crash the server.
 *  usage: add a line after the hook function definition (in the *.cpp file)
 *    CheckHookSignature(CharacterCreation, ChangeCreationInfo, default_CharacterCreation_ChangeCreationInfo);
 */

#define CheckHookSignature(cat, rule, hook) \
	static Hook_##cat##_##rule CheckSignature_##hook = hook


/** Called during character creation right after the CharCreate structure has been checked for correctness.
 *  Allows the world builder to tweak the values sent by the client prior to the actual character creation.
 */
typedef void (*Hook_CharacterCreation_ChangeCreationInfo)(CharCreate_Struct *cc);


/** Does nothing.
 */
void default_CharacterCreation_ChangeCreationInfo(CharCreate_Struct *cc);


#endif /*DEFAULT_RULES_H_*/



common/default_Hooks.cpp
------------------------
#include "../common/debug.h"
#include "../common/default_Hooks.h"


void default_CharacterCreation_ChangeCreationInfo(CharCreate_Struct *cc)
{
};
CheckHookSignature(CharacterCreation, ChangeCreationInfo, default_CharacterCreation_ChangeCreationInfo);


I did not include the changes to the VC++ projects, I am kinda scared about the result. I will just give directives : add files common/default_Hooks.h and common/default_Hooks.cpp to the Common header/Source files of the World and the Zone projects

I will make a reply to this post to show how to implement the one hook I placed in the emulator code at the moment (a hook to tweak the character info structure coming from the Everquest client, prior to the actual character creation).
Reply With Quote