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,3 +1,21 @@
#ifdef AVH_PLAYTEST_BUILD
#define AVH_NO_NEXUS
#endif
#ifdef AVH_NO_NEXUS
#include <string>
using std::string;
#include "AvHNexusClient.h"
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 <NexusClientInterface.h>
#include "AvHNexusClient.h" #include "AvHNexusClient.h"
#include "AvHNexusTunnelToServer.h" #include "AvHNexusTunnelToServer.h"
@ -117,3 +135,4 @@ string BASE64Encode(const byte_string& input)
return output; return output;
} }
#endif

View file

@ -1,3 +1,27 @@
#ifdef AVH_PLAYTEST_BUILD
#define AVH_NO_NEXUS
#endif
#ifdef AVH_NO_NEXUS
#include <string>
using std::string;
#include "AvHNexusServer.h"
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 <NexusServerInterface.h>
#include "AvHNexusServer.h" #include "AvHNexusServer.h"
#include "AvHNexusTunnelToClient.h" #include "AvHNexusTunnelToClient.h"
@ -207,3 +231,4 @@ byte_string BASE64Decode(const string& input)
} }
return output; return output;
} }
#endif

View file

@ -14,42 +14,6 @@
#include <memory> #include <memory>
#include "../Balance.txt" //default balancing source - this used to be ../Balance.txt #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 // BalanceValueContainerFactory -- facade that creates, stores, and
// maintains BalanceValueContainer objects. Multiple calls with the // maintains BalanceValueContainer objects. Multiple calls with the
@ -209,4 +173,40 @@ protected:
BalanceValueContainer(void); 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 #endif //BALANCE_H