PDA

View Full Version : Basing Gamerules off HL2MP


Marine
06-17-2007, 12:44 PM
Hey,

I tried to copy the HL2MP Gamerules and then remove all unnecessary stuff (Base it off the HL2MP Gamerules), but i borked it somewhere. Can anyone help me with getting a new set of gamerules off HL2MPRules? I know how to implement it (I've made a concommand to change it), but i can't for the life of me find how to get this working...

Anyhow, cheers ;)

Marine

Marine
06-23-2007, 09:37 AM
Bumporz. Anyone? I'm really quite stuck with this stuff :S

StuD-tos
06-23-2007, 07:29 PM
I didn't have time to test this or get rid of unnecessary included files. Compiles though.


//========= Copyright 2005-2007, Attitude Corporation, All rights reserved. ============//
//
// Author: Christopher 'StuD' Loy
// Purpose:
// File: inherited_gamerules.h
//
//================================================== ===========================//

#ifndef INHERITED_GAMERULES_H
#define INHERITED_GAMERULES_H
#pragma once

#include "gamerules.h"
#include "teamplay_gamerules.h"
#include "hl2mp_gamerules.h"
#include "gamevars_shared.h"

#ifndef CLIENT_DLL
#include "hl2mp_player.h"
#endif

#ifdef CLIENT_DLL
#define CInheritedGameRules C_InheritedGameRules
#define CInheritedGameRulesProxy C_InheritedGameRulesProxy
#endif

class CInheritedGameRulesProxy : public CHL2MPGameRulesProxy
{
public:
DECLARE_CLASS( CInheritedGameRulesProxy, CHL2MPGameRulesProxy );
DECLARE_NETWORKCLASS();
};

class CInheritedGameRules : public CHL2MPRules
{
public:
DECLARE_CLASS( CInheritedGameRules, CHL2MPRules );

#ifdef CLIENT_DLL

DECLARE_CLIENTCLASS_NOBASE(); // This makes datatables able to access our private vars.

#else

DECLARE_SERVERCLASS_NOBASE(); // This makes datatables able to access our private vars.
#endif

// Constructor
CInheritedGameRules();
// Destructor
virtual ~CInheritedGameRules();

virtual void Precache( void );
virtual bool ClientCommand( const char *pcmd, CBaseEntity *pEdict );

virtual void Think( void );

virtual const char *GetGameDescription( void ){ return "Inherited"; }

#ifndef CLIENT_DLL


#endif

private:

};

inline CInheritedGameRules* InheritedGameRules()
{
return static_cast<CInheritedGameRules*>(g_pGameRules);
}

#endif //INHERITED_GAMERULES_H



//========= Copyright 2005-2007, Attitude Corporation, All rights reserved. ============//
//
// Author: Christopher 'StuD' Loy
// Purpose:
// File: inherited_gamerules.cpp
//
//================================================== ===========================//
#include "cbase.h"
#include "inherited_gamerules.h"
#include "viewport_panel_names.h"
#include "gameeventdefs.h"
#include <KeyValues.h>
#include "ammodef.h"

#ifdef CLIENT_DLL
#include "c_hl2mp_player.h"
#else

#include "eventqueue.h"
#include "player.h"
#include "gamerules.h"
#include "game.h"
#include "items.h"
#include "entitylist.h"
#include "mapentities.h"
#include "in_buttons.h"
#include <ctype.h>
#include "voice_gamemgr.h"
#include "iscorer.h"
#include "hl2mp_player.h"
#include "weapon_hl2mpbasehlmpcombatweapon.h"
#include "team.h"
#include "voice_gamemgr.h"
#include "hl2mp_gameinterface.h"
#include "hl2mp_cvars.h"

#ifdef DEBUG
#include "hl2mp_bot_temp.h"
#endif

#endif

REGISTER_GAMERULES_CLASS( CInheritedGameRules );

BEGIN_NETWORK_TABLE_NOBASE( CInheritedGameRules, DT_InheritedGameRules )

#ifdef CLIENT_DLL

#else

#endif

END_NETWORK_TABLE()


LINK_ENTITY_TO_CLASS( inherited_gamerules, CInheritedGameRulesProxy );
IMPLEMENT_NETWORKCLASS_ALIASED( InheritedGameRulesProxy, DT_InheritedGameRulesProxy )

#ifdef CLIENT_DLL
void RecvProxy_InheritedGameRules( const RecvProp *pProp, void **pOut, void *pData, int objectID )
{
CInheritedGameRules *pRules = InheritedGameRules();
Assert( pRules );
*pOut = pRules;
}

BEGIN_RECV_TABLE( CInheritedGameRulesProxy, DT_InheritedGameRulesProxy )
RecvPropDataTable( "inherited_gamerules_data", 0, 0, &REFERENCE_RECV_TABLE( DT_InheritedGameRules ), RecvProxy_InheritedGameRules )
END_RECV_TABLE()
#else
void* SendProxy_InheritedGameRules( const SendProp *pProp, const void *pStructBase, const void *pData, CSendProxyRecipients *pRecipients, int objectID )
{
CInheritedGameRules *pRules = InheritedGameRules();
Assert( pRules );
return pRules;
}

BEGIN_SEND_TABLE( CInheritedGameRulesProxy, DT_InheritedGameRulesProxy )
SendPropDataTable( "inherited_gamerules_data", 0, &REFERENCE_SEND_TABLE( DT_InheritedGameRules ), SendProxy_InheritedGameRules )
END_SEND_TABLE()
#endif

CInheritedGameRules::CInheritedGameRules()
{
#ifndef CLIENT_DLL

#endif
}

CInheritedGameRules::~CInheritedGameRules( void )
{
#ifndef CLIENT_DLL
// Note, don't delete each team since they are in the gEntList and will
// automatically be deleted from there, instead.
g_Teams.Purge();
#endif
}

void CInheritedGameRules::Think( void )
{

#ifndef CLIENT_DLL

BaseClass::Think();

#endif
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CInheritedGameRules::Precache( void )
{
BaseClass::Precache();
}

bool CInheritedGameRules::ClientCommand(const char *pcmd, CBaseEntity *pEdict )
{

return BaseClass::ClientCommand( pcmd, pEdict );

}

Marine
06-24-2007, 06:00 AM
Woot. It's compiling, so im gonna test all the stuff in a minute... If this works, i can start on my build gamemode, and then see if i can help you with your round system :)