Added playtest configurations to win32 build

Added #define AVH_NO_NEXUS to compile NS without Nexus
Temporarily #define'd AVH_PLAYTEST_BUILD to automatically #define AVH_NO_NEXUS
Fixed Balance.h ordering issues that became apparent when BALANCE_ENABLED is #define'd.

git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@106 67975925-1194-0748-b3d5-c16f83f1a3a1
This commit is contained in:
XP-Cagey 2005-05-10 15:18:45 +00:00
parent e8cbbec941
commit 9b7e6bab76
5 changed files with 4866 additions and 328 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,32 @@
#include <NexusClientInterface.h>
#include "AvHNexusClient.h"
#include "AvHNexusTunnelToServer.h"
#include "cl_dll/hud.h"
#include "cl_dll/cl_util.h"
#ifdef AVH_PLAYTEST_BUILD
#define AVH_NO_NEXUS
#endif
string BASE64Encode(const byte_string& input);
int __MsgFunc_NexusData(const char *pszName, int iSize, void *pbuf);
#ifdef AVH_NO_NEXUS
#include <string>
using std::string;
#include "AvHNexusClient.h"
bool AvHNexus::send(const unsigned char* data, const size_t length)
{
bool AvHNexus::send(const unsigned char* data, const size_t length) { return false; }
bool AvHNexus::recv(const unsigned char* data, const size_t length) { return false; }
void AvHNexus::startup(void) {}
void AvHNexus::shutdown(void) {}
bool AvHNexus::login(const string& name, const string& password) { return true; }
bool AvHNexus::logout(void) { return true; }
#else
#include <NexusClientInterface.h>
#include "AvHNexusClient.h"
#include "AvHNexusTunnelToServer.h"
#include "cl_dll/hud.h"
#include "cl_dll/cl_util.h"
string BASE64Encode(const byte_string& input);
int __MsgFunc_NexusData(const char *pszName, int iSize, void *pbuf);
bool AvHNexus::send(const unsigned char* data, const size_t length)
{
byte_string raw_data(data,length);
string cmdline("NexusData ");
@ -23,36 +41,36 @@ bool AvHNexus::send(const unsigned char* data, const size_t length)
delete[] ptr;
return true;
}
}
bool AvHNexus::recv(const unsigned char* data, const size_t length)
{
bool AvHNexus::recv(const unsigned char* data, const size_t length)
{
byte_string raw_data(data,length);
AvHNexus::TunnelToServer::getInstance()->insertMessage(raw_data);
return true;
}
}
void AvHNexus::startup(void)
{
void AvHNexus::startup(void)
{
gEngfuncs.pfnHookUserMsg("NexusBytes", __MsgFunc_NexusData);
// Nexus::setTunnelToServer(AvHNexus::TunnelToServer::getInstance());
}
// Nexus::setTunnelToServer(AvHNexus::TunnelToServer::getInstance());
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Incominng message handler
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Incominng message handler
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int __MsgFunc_NexusData(const char *pszName, int iSize, void *pbuf)
{
int __MsgFunc_NexusData(const char *pszName, int iSize, void *pbuf)
{
AvHNexus::recv((unsigned char*)pbuf, iSize);
return iSize;
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Base 64 encoder
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Base 64 encoder
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
char Base64EncodeTable[65] = {
char Base64EncodeTable[65] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0- 7
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 8-15
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', //16-23
@ -63,9 +81,9 @@ char Base64EncodeTable[65] = {
'4', '5', '6', '7', '8', '9', '+', '/', //56-63
'=' }; //64 = padding
//debugged and working properly... do not disturb.
string BASE64Encode(const byte_string& input)
{
//debugged and working properly... do not disturb.
string BASE64Encode(const byte_string& input)
{
string output;
const byte* data = input.c_str();
size_t length = input.length();
@ -116,4 +134,5 @@ string BASE64Encode(const byte_string& input)
}
return output;
}
}
#endif

View File

@ -1,57 +1,81 @@
#include <NexusServerInterface.h>
#include "AvHNexusServer.h"
#include "AvHNexusTunnelToClient.h"
#ifdef AVH_PLAYTEST_BUILD
#define AVH_NO_NEXUS
#endif
#include "NetworkMeter.h"
extern int g_msgNexusBytes;
#ifdef AVH_NO_NEXUS
#include <string>
using std::string;
#include "AvHNexusServer.h"
byte_string BASE64Decode(const string& input);
Nexus::ServerInfo createServerInfo(void);
bool AvHNexus::send(entvars_t* const pev, const unsigned char* data, const unsigned int length) { return false; }
bool AvHNexus::recv(entvars_t* const pev, const char* data, const unsigned int length) { return false; }
string AvHNexus::getNetworkID(const edict_t* edict) { return ""; }
void AvHNexus::handleUnauthorizedJoinTeamAttempt(const edict_t* edict, const unsigned char team_index) {}
void AvHNexus::performSpeedTest(void) {}
void AvHNexus::processResponses(void) {}
void AvHNexus::setGeneratePerformanceData(const edict_t* edict, const bool generate) {}
bool AvHNexus::getGeneratePerformanceData(void) { return false; }
bool AvHNexus::isRecordingGame(void) { return false; }
void AvHNexus::cancelGame(void) {}
void AvHNexus::finishGame(void) {}
void AvHNexus::startGame(void) {}
void AvHNexus::startup(void) {}
void AvHNexus::shutdown(void) {}
#else
#include <NexusServerInterface.h>
#include "AvHNexusServer.h"
#include "AvHNexusTunnelToClient.h"
//note: we place this here so that we have the possibility of giving out AvHNetworkMessages.cpp
bool AvHNexus::send(entvars_t* const pev, const unsigned char* data, const unsigned int length)
{
#include "NetworkMeter.h"
extern int g_msgNexusBytes;
byte_string BASE64Decode(const string& input);
Nexus::ServerInfo createServerInfo(void);
//note: we place this here so that we have the possibility of giving out AvHNetworkMessages.cpp
bool AvHNexus::send(entvars_t* const pev, const unsigned char* data, const unsigned int length)
{
if( !pev ) { return false; }
MESSAGE_BEGIN( MSG_ONE, g_msgNexusBytes, NULL, pev );
for( int counter = 0; counter < length; counter++ )
{ WRITE_BYTE(data[counter]); }
MESSAGE_END();
return true;
}
}
bool AvHNexus::recv(entvars_t* const pev, const char* data, const unsigned int length)
{
bool AvHNexus::recv(entvars_t* const pev, const char* data, const unsigned int length)
{
string base64_message(data,length);
byte_string message = BASE64Decode(base64_message);
Nexus::ClientID client = OFFSET(pev);
TunnelToClient::getInstance()->insertMessage(client,message);
return true;
}
}
inline CBaseEntity* getEntity(const edict_t* edict)
{
inline CBaseEntity* getEntity(const edict_t* edict)
{
return edict == NULL ? NULL : (CBaseEntity*)edict->pvPrivateData;
}
}
string AvHNexus::getNetworkID(const edict_t* edict)
{
string AvHNexus::getNetworkID(const edict_t* edict)
{
//TODO: resolve this!
return "";
}
}
void AvHNexus::handleUnauthorizedJoinTeamAttempt(const edict_t* edict, const unsigned char team_index)
{
void AvHNexus::handleUnauthorizedJoinTeamAttempt(const edict_t* edict, const unsigned char team_index)
{
//TODO: teleport ready room player to spawn to prevent blocked doorway
}
}
void AvHNexus::performSpeedTest(void)
{
void AvHNexus::performSpeedTest(void)
{
//TODO: check permission to do this before allowing it
Nexus::testConnectionSpeed();
}
}
void AvHNexus::processResponses(void)
{
void AvHNexus::processResponses(void)
{
//TODO: do something with the responses as we consume them!
Nexus::ClientID id;
while((id = Nexus::hasHandleInfo()) != 0)
@ -70,10 +94,10 @@ void AvHNexus::processResponses(void)
{
Nexus::getPerformanceData();
}
}
}
void AvHNexus::setGeneratePerformanceData(const edict_t* edict, const bool generate)
{
void AvHNexus::setGeneratePerformanceData(const edict_t* edict, const bool generate)
{
//TODO: check permission to do this before allowing it
Nexus::setGeneratePerformanceData(generate);
CBaseEntity* player = getEntity(edict);
@ -85,60 +109,60 @@ void AvHNexus::setGeneratePerformanceData(const edict_t* edict, const bool gener
{
UTIL_SayText("Nexus Profiling is now OFF", player);
}
}
}
bool AvHNexus::getGeneratePerformanceData(void)
{
bool AvHNexus::getGeneratePerformanceData(void)
{
return Nexus::getGeneratePerformanceData();
}
}
bool AvHNexus::isRecordingGame(void)
{
bool AvHNexus::isRecordingGame(void)
{
return Nexus::isRecordingEvent();
}
}
void AvHNexus::cancelGame(void)
{
void AvHNexus::cancelGame(void)
{
Nexus::reportEventCancelled();
}
}
void AvHNexus::finishGame(void)
{
void AvHNexus::finishGame(void)
{
Nexus::EventResultInfo info;
Nexus::reportEventFinished(info);
}
}
void AvHNexus::startGame(void)
{
void AvHNexus::startGame(void)
{
Nexus::EventInfo info;
Nexus::reportEventStarted(info);
}
}
void AvHNexus::startup(void)
{
void AvHNexus::startup(void)
{
Nexus::setTunnelToClient(TunnelToClient::getInstance());
Nexus::setProductName("Natural Selection-temp product");
Nexus::connect(createServerInfo());
}
}
void AvHNexus::shutdown(void)
{
void AvHNexus::shutdown(void)
{
Nexus::disconnect();
}
}
Nexus::ServerInfo(createServerInfo())
{
Nexus::ServerInfo(createServerInfo())
{
Nexus::ServerInfo info;
info.setName( string( CVAR_GET_STRING( "hostname" ) ) );
info.setProduct( Nexus::getProductName() );
return info;
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Base 64 decoder
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Base 64 decoder
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
byte Base64DecodeTable[256] = {
byte Base64DecodeTable[256] = {
0, 0, 0, 0, 0, 0, 0, 0, // 0- 7
0, 0, 0, 0, 0, 0, 0, 0, // 8- 15
0, 0, 0, 0, 0, 0, 0, 0, // 16- 23
@ -171,11 +195,11 @@ byte Base64DecodeTable[256] = {
0, 0, 0, 0, 0, 0, 0, 0, //232-239
0, 0, 0, 0, 0, 0, 0, 0, //240-247
0, 0, 0, 0, 0, 0, 0, 0 //248-255
};
};
//debugged and working properly... do not disturb.
byte_string BASE64Decode(const string& input)
{
//debugged and working properly... do not disturb.
byte_string BASE64Decode(const string& input)
{
byte_string output;
const byte* data = (const byte*)input.c_str();
size_t length = input.length();
@ -206,4 +230,5 @@ byte_string BASE64Decode(const string& input)
data += 4; length -= 4;
}
return output;
}
}
#endif

View File

@ -14,42 +14,6 @@
#include <memory>
#include "../Balance.txt" //default balancing source - this used to be ../Balance.txt
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// BALANCE_VAR(x) macro - the heart of the balance system, ties value
// to default balance source if PLAYTEST_BUILD is enabled, uses
// hardcoded value otherwise. Place the name of the varaible #define
// in Balance.txt as the value in the macro.
//
// BALANCE_LISTENER(x) macro - for registering global
// BalanceChangeListeners (see below), reverts to no operation
// if AVH_PLAYTEST_BUILD isn't enabled.
//
// BALANCE_FIELD_LISTENER(x,y) macro - for registering field-specific
// BalanceChangeListeners, reverts to no operation if
// BALANCE_ENABLED isn't defined
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#ifdef BALANCE_ENABLED //use Balance.txt values on server, no-source/explicitly set values for client
#ifdef SERVER
#define BALANCE_DEFNAME BalanceVarContainerFactory::getDefaultFilename()
#else
#define BALANCE_DEFNAME ""
#endif
inline void BALANCE_LISTENER(const BalanceChangeListener* object) { BalanceValueContainerFactory::get(BALANCE_DEFNAME)->addListener(object); }
inline void BALANCE_FIELD_LISTENER(const BalanceChangeListener* object, const char* field) { BalanceValueContainerFactory::get(BALANCE_DEFNAME)->addListener(object,field); }
#define BALANCE_VAR(name) GetBalanceVar(#name,name) //requires macro for string-izing of name
inline int GetBalanceVar(const char* name, const int value) { BalanceValueContainerFactory::get(BALANCE_DEFNAME)->get(name,value); }
inline float GetBalanceVar(const char* name, const float value) { BalanceValueContainerFactory::get(BALANCE_DEFNAME)->get(name,value); }
inline float GetBalanceVar(const char* name, const double value) { BalanceValueContainerFactory::get(BALANCE_DEFNAME)->get(name,(float)value); }
inline std::string GetBalanceVar(const char* name, const char* value) { BalanceValueContainerFactory::get(BALANCE_DEFNAME)->get(name,value); }
#else
#define BALANCE_VAR(name) name //hardcodes the value at compile time
#define BALANCE_LISTENER(object)
#define BALANCE_FIELD_LISTENER(object,name)
#endif //BALANCE_ENABLED
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// BalanceValueContainerFactory -- facade that creates, stores, and
// maintains BalanceValueContainer objects. Multiple calls with the
@ -209,4 +173,40 @@ protected:
BalanceValueContainer(void);
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// BALANCE_VAR(x) macro - the heart of the balance system, ties value
// to default balance source if PLAYTEST_BUILD is enabled, uses
// hardcoded value otherwise. Place the name of the varaible #define
// in Balance.txt as the value in the macro.
//
// BALANCE_LISTENER(x) macro - for registering global
// BalanceChangeListeners (see below), reverts to no operation
// if AVH_PLAYTEST_BUILD isn't enabled.
//
// BALANCE_FIELD_LISTENER(x,y) macro - for registering field-specific
// BalanceChangeListeners, reverts to no operation if
// BALANCE_ENABLED isn't defined
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#ifdef BALANCE_ENABLED //use Balance.txt values on server, no-source/explicitly set values for client
#ifdef SERVER
#define BALANCE_DEFNAME BalanceValueContainerFactory::getDefaultFilename()
#else
#define BALANCE_DEFNAME ""
#endif
inline void BALANCE_LISTENER(const BalanceChangeListener* object) { BalanceValueContainerFactory::get(BALANCE_DEFNAME)->addListener(object); }
inline void BALANCE_FIELD_LISTENER(const BalanceChangeListener* object, const char* field) { BalanceValueContainerFactory::get(BALANCE_DEFNAME)->addListener(field,object); }
#define BALANCE_VAR(name) GetBalanceVar(#name,name) //requires macro for string-izing of name
inline int GetBalanceVar(const char* name, const int value) { return BalanceValueContainerFactory::get(BALANCE_DEFNAME)->get(name,value); }
inline float GetBalanceVar(const char* name, const float value) { return BalanceValueContainerFactory::get(BALANCE_DEFNAME)->get(name,value); }
inline float GetBalanceVar(const char* name, const double value) { return BalanceValueContainerFactory::get(BALANCE_DEFNAME)->get(name,(float)value); }
inline std::string GetBalanceVar(const char* name, const char* value) { return BalanceValueContainerFactory::get(BALANCE_DEFNAME)->get(name,value); }
#else
#define BALANCE_VAR(name) name //hardcodes the value at compile time
#define BALANCE_LISTENER(object)
#define BALANCE_FIELD_LISTENER(object,name)
#endif //BALANCE_ENABLED
#endif //BALANCE_H