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,119 +1,138 @@
#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)
{
byte_string raw_data(data,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; }
string cmdline("NexusData ");
cmdline += BASE64Encode(raw_data);
cmdline += "\n";
void AvHNexus::startup(void) {}
void AvHNexus::shutdown(void) {}
//ugliness due to pfnClientCmd wanting a non-const ptr
char* ptr = new char[cmdline.length()+1];
strncpy(ptr,cmdline.c_str(),cmdline.length());
ptr[cmdline.length()] = '\0';
gEngfuncs.pfnClientCmd(ptr);
delete[] ptr;
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"
return true;
}
string BASE64Encode(const byte_string& input);
int __MsgFunc_NexusData(const char *pszName, int iSize, void *pbuf);
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)
{
gEngfuncs.pfnHookUserMsg("NexusBytes", __MsgFunc_NexusData);
// Nexus::setTunnelToServer(AvHNexus::TunnelToServer::getInstance());
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Incominng message handler
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int __MsgFunc_NexusData(const char *pszName, int iSize, void *pbuf)
{
AvHNexus::recv((unsigned char*)pbuf, iSize);
return iSize;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Base 64 encoder
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', //24-31
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', //32-39
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', //40-47
'w', 'x', 'y', 'z', '0', '1', '2', '3', //48-55
'4', '5', '6', '7', '8', '9', '+', '/', //56-63
'=' }; //64 = padding
//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();
int value, value2;
//handle input in 3 byte blocks
while( length > 2 )
bool AvHNexus::send(const unsigned char* data, const size_t length)
{
value = data[0]; value >>= 2;
output.push_back(Base64EncodeTable[value]);
value = data[0]; value2 = data[1];
value &= 0x03; value <<= 4;
value2 &= 0xF0; value2 >>= 4; value |= value2;
output.push_back(Base64EncodeTable[value]);
value = data[1]; value2 = data[2];
value &= 0x0F; value <<= 2;
value2 &= 0xC0; value2 >>= 6; value |= value2;
output.push_back(Base64EncodeTable[value]);
value = data[2]; value &= 0x3F;
output.push_back(Base64EncodeTable[value]);
data += 3; length -= 3;
byte_string raw_data(data,length);
string cmdline("NexusData ");
cmdline += BASE64Encode(raw_data);
cmdline += "\n";
//ugliness due to pfnClientCmd wanting a non-const ptr
char* ptr = new char[cmdline.length()+1];
strncpy(ptr,cmdline.c_str(),cmdline.length());
ptr[cmdline.length()] = '\0';
gEngfuncs.pfnClientCmd(ptr);
delete[] ptr;
return true;
}
//handle remainder
switch(length)
bool AvHNexus::recv(const unsigned char* data, const size_t length)
{
case 0: //no remainder to process
break;
case 1: //process and pad with two =
value = data[0]; value >>= 2;
output.push_back(Base64EncodeTable[value]);
value = data[0]; value &= 0x03; value <<= 4;
output.push_back(Base64EncodeTable[value]);
output.push_back(Base64EncodeTable[64]);
output.push_back(Base64EncodeTable[64]);
break;
case 2: //process and pad with one =
value = data[0]; value >>= 2;
output.push_back(Base64EncodeTable[value]);
value = data[0]; value2 = data[1];
value &= 0x03; value <<= 4;
value2 &= 0xF0; value2 >>= 4; value |= value2;
output.push_back(Base64EncodeTable[value]);
value = data[1]; value &= 0x0F; value <<= 2;
output.push_back(Base64EncodeTable[value]);
output.push_back(Base64EncodeTable[64]);
break;
byte_string raw_data(data,length);
AvHNexus::TunnelToServer::getInstance()->insertMessage(raw_data);
return true;
}
void AvHNexus::startup(void)
{
gEngfuncs.pfnHookUserMsg("NexusBytes", __MsgFunc_NexusData);
// Nexus::setTunnelToServer(AvHNexus::TunnelToServer::getInstance());
}
return output;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Incominng message handler
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int __MsgFunc_NexusData(const char *pszName, int iSize, void *pbuf)
{
AvHNexus::recv((unsigned char*)pbuf, iSize);
return iSize;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Base 64 encoder
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', //24-31
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', //32-39
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', //40-47
'w', 'x', 'y', 'z', '0', '1', '2', '3', //48-55
'4', '5', '6', '7', '8', '9', '+', '/', //56-63
'=' }; //64 = padding
//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();
int value, value2;
//handle input in 3 byte blocks
while( length > 2 )
{
value = data[0]; value >>= 2;
output.push_back(Base64EncodeTable[value]);
value = data[0]; value2 = data[1];
value &= 0x03; value <<= 4;
value2 &= 0xF0; value2 >>= 4; value |= value2;
output.push_back(Base64EncodeTable[value]);
value = data[1]; value2 = data[2];
value &= 0x0F; value <<= 2;
value2 &= 0xC0; value2 >>= 6; value |= value2;
output.push_back(Base64EncodeTable[value]);
value = data[2]; value &= 0x3F;
output.push_back(Base64EncodeTable[value]);
data += 3; length -= 3;
}
//handle remainder
switch(length)
{
case 0: //no remainder to process
break;
case 1: //process and pad with two =
value = data[0]; value >>= 2;
output.push_back(Base64EncodeTable[value]);
value = data[0]; value &= 0x03; value <<= 4;
output.push_back(Base64EncodeTable[value]);
output.push_back(Base64EncodeTable[64]);
output.push_back(Base64EncodeTable[64]);
break;
case 2: //process and pad with one =
value = data[0]; value >>= 2;
output.push_back(Base64EncodeTable[value]);
value = data[0]; value2 = data[1];
value &= 0x03; value <<= 4;
value2 &= 0xF0; value2 >>= 4; value |= value2;
output.push_back(Base64EncodeTable[value]);
value = data[1]; value &= 0x0F; value <<= 2;
output.push_back(Base64EncodeTable[value]);
output.push_back(Base64EncodeTable[64]);
break;
}
return output;
}
#endif

View File

@ -1,209 +1,234 @@
#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)
{
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;
}
#include "NetworkMeter.h"
extern int g_msgNexusBytes;
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;
}
byte_string BASE64Decode(const string& input);
Nexus::ServerInfo createServerInfo(void);
inline CBaseEntity* getEntity(const edict_t* edict)
{
return edict == NULL ? NULL : (CBaseEntity*)edict->pvPrivateData;
}
string AvHNexus::getNetworkID(const edict_t* edict)
{
//TODO: resolve this!
return "";
}
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)
{
//TODO: check permission to do this before allowing it
Nexus::testConnectionSpeed();
}
void AvHNexus::processResponses(void)
{
//TODO: do something with the responses as we consume them!
Nexus::ClientID id;
while((id = Nexus::hasHandleInfo()) != 0)
//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)
{
Nexus::getHandleInfo(id);
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;
}
while((id = Nexus::hasHistoryInfo()) != 0)
bool AvHNexus::recv(entvars_t* const pev, const char* data, const unsigned int length)
{
Nexus::getHistoryInfo(id);
string base64_message(data,length);
byte_string message = BASE64Decode(base64_message);
Nexus::ClientID client = OFFSET(pev);
TunnelToClient::getInstance()->insertMessage(client,message);
return true;
}
while(Nexus::hasErrorReport())
inline CBaseEntity* getEntity(const edict_t* edict)
{
Nexus::getErrorReport();
return edict == NULL ? NULL : (CBaseEntity*)edict->pvPrivateData;
}
while(Nexus::hasPerformanceData())
string AvHNexus::getNetworkID(const edict_t* edict)
{
Nexus::getPerformanceData();
//TODO: resolve this!
return "";
}
}
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);
if(player && AvHNexus::getGeneratePerformanceData())
void AvHNexus::handleUnauthorizedJoinTeamAttempt(const edict_t* edict, const unsigned char team_index)
{
UTIL_SayText("Nexus Profiling is now ON", player);
//TODO: teleport ready room player to spawn to prevent blocked doorway
}
else
void AvHNexus::performSpeedTest(void)
{
UTIL_SayText("Nexus Profiling is now OFF", player);
//TODO: check permission to do this before allowing it
Nexus::testConnectionSpeed();
}
}
bool AvHNexus::getGeneratePerformanceData(void)
{
return Nexus::getGeneratePerformanceData();
}
bool AvHNexus::isRecordingGame(void)
{
return Nexus::isRecordingEvent();
}
void AvHNexus::cancelGame(void)
{
Nexus::reportEventCancelled();
}
void AvHNexus::finishGame(void)
{
Nexus::EventResultInfo info;
Nexus::reportEventFinished(info);
}
void AvHNexus::startGame(void)
{
Nexus::EventInfo info;
Nexus::reportEventStarted(info);
}
void AvHNexus::startup(void)
{
Nexus::setTunnelToClient(TunnelToClient::getInstance());
Nexus::setProductName("Natural Selection-temp product");
Nexus::connect(createServerInfo());
}
void AvHNexus::shutdown(void)
{
Nexus::disconnect();
}
Nexus::ServerInfo(createServerInfo())
{
Nexus::ServerInfo info;
info.setName( string( CVAR_GET_STRING( "hostname" ) ) );
info.setProduct( Nexus::getProductName() );
return info;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Base 64 decoder
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
0, 0, 0, 0, 0, 0, 0, 0, // 24- 31
0, 0, 0, 0, 0, 0, 0, 0, // 32- 39
0, 0, 0, 62, 0, 0, 0, 63, // 40- 47 ( 43 = '+', 47 = '/')
52, 53, 54, 55, 56, 57, 58, 59, // 48- 55 ( 48- 55 = 0-7)
60, 61, 0, 0, 0, 0, 0, 0, // 56- 63 ( 56- 57 = 8-9)
0, 0, 1, 2, 3, 4, 5, 6, // 64- 71 ( 65- 71 = A-G)
7, 8, 9, 10, 11, 12, 13, 14, // 72- 79 ( 72- 79 = H-O)
15, 16, 17, 18, 19, 20, 21, 22, // 80- 87 ( 80- 87 = P-W)
23, 24, 25, 0, 0, 0, 0, 0, // 88- 95 ( 88- 90 = X-Z)
0, 26, 27, 28, 29, 30, 31, 32, // 96 003 ( 97 003 = a-g)
33, 34, 35, 36, 37, 38, 39, 40, //104 011 (104-111 = h-o)
41, 42, 43, 44, 45, 46, 47, 48, //112 019 (112-119 = p-w)
49, 50, 51, 0, 0, 0, 0, 0, //120 027 (120-122 = x-z)
0, 0, 0, 0, 0, 0, 0, 0, //128 035
0, 0, 0, 0, 0, 0, 0, 0, //136 043
0, 0, 0, 0, 0, 0, 0, 0, //144 051
0, 0, 0, 0, 0, 0, 0, 0, //152 059
0, 0, 0, 0, 0, 0, 0, 0, //160 067
0, 0, 0, 0, 0, 0, 0, 0, //168 075
0, 0, 0, 0, 0, 0, 0, 0, //176 083
0, 0, 0, 0, 0, 0, 0, 0, //184 091
0, 0, 0, 0, 0, 0, 0, 0, //192 099
0, 0, 0, 0, 0, 0, 0, 0, //200-207
0, 0, 0, 0, 0, 0, 0, 0, //208-215
0, 0, 0, 0, 0, 0, 0, 0, //216-223
0, 0, 0, 0, 0, 0, 0, 0, //224-231
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)
{
byte_string output;
const byte* data = (const byte*)input.c_str();
size_t length = input.length();
byte value, value2;
while( length > 0 )
void AvHNexus::processResponses(void)
{
value = Base64DecodeTable[data[0]];
value2 = Base64DecodeTable[data[1]];
value <<= 2;
value2 &= 0x30; value2 >>= 4; value |= value2;
output.push_back(value);
if( data[2] != '=' )
//TODO: do something with the responses as we consume them!
Nexus::ClientID id;
while((id = Nexus::hasHandleInfo()) != 0)
{
value = Base64DecodeTable[data[1]];
value2 = Base64DecodeTable[data[2]];
value &= 0x0F; value <<= 4;
value2 &= 0x3C; value2 >>= 2; value |= value2;
output.push_back(value);
Nexus::getHandleInfo(id);
}
if( data[3] != '=' )
while((id = Nexus::hasHistoryInfo()) != 0)
{
value = Base64DecodeTable[data[2]];
value &= 0x03; value <<= 6;
value |= Base64DecodeTable[data[3]];
output.push_back(value);
Nexus::getHistoryInfo(id);
}
while(Nexus::hasErrorReport())
{
Nexus::getErrorReport();
}
while(Nexus::hasPerformanceData())
{
Nexus::getPerformanceData();
}
data += 4; length -= 4;
}
return output;
}
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);
if(player && AvHNexus::getGeneratePerformanceData())
{
UTIL_SayText("Nexus Profiling is now ON", player);
}
else
{
UTIL_SayText("Nexus Profiling is now OFF", player);
}
}
bool AvHNexus::getGeneratePerformanceData(void)
{
return Nexus::getGeneratePerformanceData();
}
bool AvHNexus::isRecordingGame(void)
{
return Nexus::isRecordingEvent();
}
void AvHNexus::cancelGame(void)
{
Nexus::reportEventCancelled();
}
void AvHNexus::finishGame(void)
{
Nexus::EventResultInfo info;
Nexus::reportEventFinished(info);
}
void AvHNexus::startGame(void)
{
Nexus::EventInfo info;
Nexus::reportEventStarted(info);
}
void AvHNexus::startup(void)
{
Nexus::setTunnelToClient(TunnelToClient::getInstance());
Nexus::setProductName("Natural Selection-temp product");
Nexus::connect(createServerInfo());
}
void AvHNexus::shutdown(void)
{
Nexus::disconnect();
}
Nexus::ServerInfo(createServerInfo())
{
Nexus::ServerInfo info;
info.setName( string( CVAR_GET_STRING( "hostname" ) ) );
info.setProduct( Nexus::getProductName() );
return info;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Base 64 decoder
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
0, 0, 0, 0, 0, 0, 0, 0, // 24- 31
0, 0, 0, 0, 0, 0, 0, 0, // 32- 39
0, 0, 0, 62, 0, 0, 0, 63, // 40- 47 ( 43 = '+', 47 = '/')
52, 53, 54, 55, 56, 57, 58, 59, // 48- 55 ( 48- 55 = 0-7)
60, 61, 0, 0, 0, 0, 0, 0, // 56- 63 ( 56- 57 = 8-9)
0, 0, 1, 2, 3, 4, 5, 6, // 64- 71 ( 65- 71 = A-G)
7, 8, 9, 10, 11, 12, 13, 14, // 72- 79 ( 72- 79 = H-O)
15, 16, 17, 18, 19, 20, 21, 22, // 80- 87 ( 80- 87 = P-W)
23, 24, 25, 0, 0, 0, 0, 0, // 88- 95 ( 88- 90 = X-Z)
0, 26, 27, 28, 29, 30, 31, 32, // 96 003 ( 97 003 = a-g)
33, 34, 35, 36, 37, 38, 39, 40, //104 011 (104-111 = h-o)
41, 42, 43, 44, 45, 46, 47, 48, //112 019 (112-119 = p-w)
49, 50, 51, 0, 0, 0, 0, 0, //120 027 (120-122 = x-z)
0, 0, 0, 0, 0, 0, 0, 0, //128 035
0, 0, 0, 0, 0, 0, 0, 0, //136 043
0, 0, 0, 0, 0, 0, 0, 0, //144 051
0, 0, 0, 0, 0, 0, 0, 0, //152 059
0, 0, 0, 0, 0, 0, 0, 0, //160 067
0, 0, 0, 0, 0, 0, 0, 0, //168 075
0, 0, 0, 0, 0, 0, 0, 0, //176 083
0, 0, 0, 0, 0, 0, 0, 0, //184 091
0, 0, 0, 0, 0, 0, 0, 0, //192 099
0, 0, 0, 0, 0, 0, 0, 0, //200-207
0, 0, 0, 0, 0, 0, 0, 0, //208-215
0, 0, 0, 0, 0, 0, 0, 0, //216-223
0, 0, 0, 0, 0, 0, 0, 0, //224-231
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)
{
byte_string output;
const byte* data = (const byte*)input.c_str();
size_t length = input.length();
byte value, value2;
while( length > 0 )
{
value = Base64DecodeTable[data[0]];
value2 = Base64DecodeTable[data[1]];
value <<= 2;
value2 &= 0x30; value2 >>= 4; value |= value2;
output.push_back(value);
if( data[2] != '=' )
{
value = Base64DecodeTable[data[1]];
value2 = Base64DecodeTable[data[2]];
value &= 0x0F; value <<= 4;
value2 &= 0x3C; value2 >>= 2; value |= value2;
output.push_back(value);
}
if( data[3] != '=' )
{
value = Base64DecodeTable[data[2]];
value &= 0x03; value <<= 6;
value |= Base64DecodeTable[data[3]];
output.push_back(value);
}
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