some more to try...

This commit is contained in:
DarthArgus
2016-07-24 21:36:20 -07:00
parent e65b05ada9
commit 9d2013918a
5 changed files with 2516 additions and 2571 deletions
File diff suppressed because it is too large Load Diff
@@ -29,15 +29,15 @@ const TriggerVolumeData DefaultTriggerVolumeData;
bool ServerXpManagerObjectTemplate::ms_allowDefaultTemplateParams = true;
/**
* Class constructor.
*/
ServerXpManagerObjectTemplate::ServerXpManagerObjectTemplate(const std::string & filename)
//@BEGIN TFD INIT
: ServerUniverseObjectTemplate(filename)
,m_versionOk(true)
//@END TFD INIT
, m_versionOk(true)
, m_templateVersion(0)
//@END TFD INIT
{
} // ServerXpManagerObjectTemplate::ServerXpManagerObjectTemplate
@@ -46,8 +46,8 @@ ServerXpManagerObjectTemplate::ServerXpManagerObjectTemplate(const std::string &
*/
ServerXpManagerObjectTemplate::~ServerXpManagerObjectTemplate()
{
//@BEGIN TFD CLEANUP
//@END TFD CLEANUP
//@BEGIN TFD CLEANUP
//@END TFD CLEANUP
} // ServerXpManagerObjectTemplate::~ServerXpManagerObjectTemplate
/**
@@ -110,7 +110,7 @@ Tag ServerXpManagerObjectTemplate::getHighestTemplateVersion(void) const
*/
Object * ServerXpManagerObjectTemplate::createObject(void) const
{
// return new XpManagerObject(this);
// return new XpManagerObject(this);
return nullptr;
} // ServerXpManagerObjectTemplate::createObject
@@ -124,8 +124,8 @@ Object * ServerXpManagerObjectTemplate::createObject(void) const
*/
void ServerXpManagerObjectTemplate::load(Iff &file)
{
static const int MAX_NAME_SIZE = 256;
char paramName[MAX_NAME_SIZE];
static const int MAX_NAME_SIZE = 256;
char paramName[MAX_NAME_SIZE];
if (file.getCurrentName() != ServerXpManagerObjectTemplate_tag)
{
@@ -135,7 +135,7 @@ char paramName[MAX_NAME_SIZE];
file.enterForm();
m_templateVersion = file.getCurrentName();
if (m_templateVersion == TAG(D,E,R,V))
if (m_templateVersion == TAG(D, E, R, V))
{
file.enterForm();
file.enterChunk();
@@ -155,10 +155,8 @@ char paramName[MAX_NAME_SIZE];
file.exitForm();
m_templateVersion = file.getCurrentName();
}
if (getHighestTemplateVersion() != TAG(0,0,0,0))
if (getHighestTemplateVersion() != TAG(0, 0, 0, 0))
{
m_versionOk = false;
}
@@ -176,4 +174,4 @@ char paramName[MAX_NAME_SIZE];
return;
} // ServerXpManagerObjectTemplate::load
//@END TFD
//@END TFD
@@ -2,7 +2,6 @@
// copyright 2000 Verant Interactive
// Author: Justin Randall
//-----------------------------------------------------------------------
#include "serverKeyShare/FirstServerKeyShare.h"
@@ -13,13 +12,13 @@
//-----------------------------------------------------------------------
KeyShare::Token::Token(const unsigned char * const newCipherData,
const uint32 newDataLen,
const unsigned char newDigest[KeyShareConstants::keyLength],
const uint32 newCipherDataLen) :
cipherData(0),
cipherDataLen(newCipherDataLen),
dataLen(newDataLen)
KeyShare::Token::Token(const unsigned char * const newCipherData,
const uint32 newDataLen,
const unsigned char newDigest[KeyShareConstants::keyLength],
const uint32 newCipherDataLen) :
cipherData(0),
cipherDataLen(newCipherDataLen),
dataLen(newDataLen)
{
cipherData = new unsigned char[cipherDataLen];
memcpy(cipherData, newCipherData, cipherDataLen);
@@ -29,9 +28,9 @@ dataLen(newDataLen)
//-----------------------------------------------------------------------
KeyShare::Token::Token(const Token & source) :
cipherData(0),
cipherDataLen(source.cipherDataLen),
dataLen(source.dataLen)
cipherData(0),
cipherDataLen(source.cipherDataLen),
dataLen(source.dataLen)
{
cipherData = new unsigned char[cipherDataLen];
memcpy(cipherData, source.cipherData, cipherDataLen);
@@ -39,25 +38,25 @@ dataLen(source.dataLen)
}
//-----------------------------------------------------------------------
KeyShare::Token::Token(Archive::ReadIterator & source) :
cipherData(0),
cipherDataLen(0),
dataLen(0)
cipherData(0),
cipherDataLen(0),
dataLen(0)
{
Archive::get(source, cipherDataLen);
// if the cipher data has been tampered with, don't unpack it. The vaidation will fail
if(cipherDataLen < 64)
if (cipherDataLen < 64)
{
Archive::get(source, dataLen);
cipherData = new unsigned char[cipherDataLen];
unsigned int i;
for(i = 0; i < cipherDataLen; i ++)
for (i = 0; i < cipherDataLen; i++)
{
Archive::get(source, cipherData[i]);
}
for(i = 0; i < KeyShareConstants::keyLength; i ++)
for (i = 0; i < KeyShareConstants::keyLength; i++)
{
Archive::get(source, digest[i]);
}
@@ -112,11 +111,11 @@ void KeyShare::Token::pack(Archive::ByteStream & target) const
Archive::put(target, cipherDataLen);
Archive::put(target, dataLen);
unsigned int i;
for(i = 0; i < cipherDataLen; i ++)
for (i = 0; i < cipherDataLen; i++)
{
Archive::put(target, cipherData[i]);
}
for(i = 0; i < KeyShareConstants::keyLength; i ++)
for (i = 0; i < KeyShareConstants::keyLength; i++)
{
Archive::put(target, digest[i]);
}
@@ -125,17 +124,17 @@ void KeyShare::Token::pack(Archive::ByteStream & target) const
//-----------------------------------------------------------------------
KeyShare::KeyShare(const unsigned int newKeyCount) :
decryptors(0),
encryptors(0),
hasher(0),
keyCount(newKeyCount),
keys(0)
decryptors(0),
encryptors(0),
hasher(0),
keyCount(newKeyCount),
keys(0)
{
keys = new Key[keyCount];
decryptors = new Crypto::TwofishDecryptor *[keyCount];
encryptors = new Crypto::TwofishEncryptor *[keyCount];
for(unsigned int i = 0; i < keyCount; i ++)
for (unsigned int i = 0; i < keyCount; i++)
{
decryptors[i] = 0;
encryptors[i] = 0;
@@ -148,7 +147,7 @@ keys(0)
KeyShare::~KeyShare()
{
delete[] keys;
for(unsigned int i = 0; i < keyCount; i ++)
for (unsigned int i = 0; i < keyCount; i++)
{
delete decryptors[i];
delete encryptors[i];
@@ -164,7 +163,7 @@ KeyShare::~KeyShare()
bool KeyShare::decipherToken(const KeyShare::Token & token, unsigned char * clearTextData, uint32 & dataLen) const
{
bool result = false;
if(dataLen < token.getDataLen())
if (dataLen < token.getDataLen())
{
dataLen = token.getDataLen();
}
@@ -175,10 +174,10 @@ bool KeyShare::decipherToken(const KeyShare::Token & token, unsigned char * clea
unsigned char * clearText = new unsigned char[cipherDataLen];
memcpy(cipherText, token.getData(), cipherDataLen);
for(unsigned int i = 0; i < keyCount; i ++)
for (unsigned int i = 0; i < keyCount; i++)
{
DEBUG_REPORT_LOG(true, ("Decrypting with key: "));
for(uint32 j = 0; j < 16; j ++)
for (uint32 j = 0; j < 16; j++)
{
DEBUG_REPORT_LOG(true, ("[%3i] ", keys[i].value[j]));
}
@@ -193,10 +192,10 @@ bool KeyShare::decipherToken(const KeyShare::Token & token, unsigned char * clea
NOT_NULL(hasher);
result = hasher->verify(digest, clearTextData, dataLen);
if(result)
if (result)
{
DEBUG_REPORT_LOG(true, ("succeeded\n"));
break;
}
else
@@ -215,14 +214,14 @@ bool KeyShare::decipherToken(const KeyShare::Token & token, unsigned char * clea
void KeyShare::decrypt(const unsigned char * const sourceBuffer, const uint32 sourceBufferSize, unsigned char * resultBuffer, const uint32 keyIndex) const
{
const uint32 blockSize = decryptors[0]->getBlockSize();
unsigned char * inBlock = new unsigned char [blockSize];
unsigned char * outBlock = new unsigned char [blockSize];
unsigned char * inBlock = new unsigned char[blockSize];
unsigned char * outBlock = new unsigned char[blockSize];
memset(resultBuffer, 0, sourceBufferSize);
for(uint32 i = 0; i < sourceBufferSize; i += blockSize)
for (uint32 i = 0; i < sourceBufferSize; i += blockSize)
{
if(i + blockSize > sourceBufferSize)
if (i + blockSize > sourceBufferSize)
memcpy(inBlock, &sourceBuffer[i], sourceBufferSize - i);
else
memcpy(inBlock, &sourceBuffer[i], blockSize);
@@ -241,7 +240,7 @@ const uint32 KeyShare::encrypt(const unsigned char * const sourceData, const uin
const uint32 blockSize = encryptors[0]->getBlockSize();
// calculate the size of the encrypted result buffer
if(sourceDataSize % blockSize)
if (sourceDataSize % blockSize)
{
// if it's larger than some multiple of the cipher block size ....
i = static_cast<uint32>((sourceDataSize / blockSize) + 1) * blockSize;
@@ -251,22 +250,22 @@ const uint32 KeyShare::encrypt(const unsigned char * const sourceData, const uin
// it's already aligned on the cipher block byte boundary
i = sourceDataSize;
}
*resultBuffer = new unsigned char [i];
*resultBuffer = new unsigned char[i];
DEBUG_REPORT_LOG(true, ("Encrypting with key: "));
for(i = 0; i < 16; i ++)
for (i = 0; i < 16; i++)
{
DEBUG_REPORT_LOG(true, ("[%3i] ", keys[0].value[i]));
}
DEBUG_REPORT_LOG(true, ("\n"));
unsigned char * inBlock = new unsigned char [blockSize];
unsigned char * outBlock = new unsigned char [blockSize];
for(i = 0; i < sourceDataSize; i += 16)
unsigned char * inBlock = new unsigned char[blockSize];
unsigned char * outBlock = new unsigned char[blockSize];
for (i = 0; i < sourceDataSize; i += 16)
{
memset(inBlock, 0, KeyShareConstants::keyLength);
if(i + blockSize > sourceDataSize)
if (i + blockSize > sourceDataSize)
memcpy(inBlock, &sourceData[i], sourceDataSize - i);
else
memcpy(inBlock, &sourceData[i], KeyShareConstants::keyLength);
@@ -283,10 +282,9 @@ const uint32 KeyShare::encrypt(const unsigned char * const sourceData, const uin
bool KeyShare::hasKey(const Key & source)
{
for(unsigned int i = 0; i < getKeyCount(); i ++)
for (unsigned int i = 0; i < getKeyCount(); i++)
{
if(memcmp(source.value, keys[i].value, KeyShareConstants::keyLength) == 0)
if (memcmp(source.value, keys[i].value, KeyShareConstants::keyLength) == 0)
return true;
}
return false;
@@ -306,7 +304,7 @@ KeyShare::Token KeyShare::makeToken(const unsigned char * const data, const uint
// encrypt the digest
unsigned char * cipherDigest;
IGNORE_RETURN(encrypt(digest, KeyShareConstants::keyLength, &cipherDigest)); ///@todo error checking
// encrypt the cleartext data
unsigned char * cipherData = 0;
uint32 cipherDataLen = encrypt(data, dataLen, &cipherData);
@@ -314,7 +312,7 @@ KeyShare::Token KeyShare::makeToken(const unsigned char * const data, const uint
// build a token using the ciphertext data and digest
Token token(cipherData, dataLen, cipherDigest, cipherDataLen);
// clean up allocation for cipher text,
// clean up allocation for cipher text,
// it was deep copied in the token
delete[] cipherData;
delete[] cipherDigest;
@@ -347,7 +345,7 @@ void KeyShare::setKey(const Key & newKey, const unsigned int index)
void KeyShare::shift(void)
{
// shift key array
for(unsigned int i = getKeyCount() - 1; i > 0; i --)
for (unsigned int i = getKeyCount() - 1; i > 0; i--)
{
setKey(getKey(i - 1), i);
}
@@ -356,14 +354,15 @@ void KeyShare::shift(void)
//-----------------------------------------------------------------------
AutoVariableKeyShare::AutoVariableKeyShare() :
AutoVariableBase()
AutoVariableBase(),
value()
{
}
//-----------------------------------------------------------------------
AutoVariableKeyShare::AutoVariableKeyShare(const KeyShare::Key & source) :
AutoVariableBase()
AutoVariableBase()
{
value = source;
}
@@ -400,17 +399,16 @@ AutoVariableKeyShare::operator const KeyShare::Key & () const
void AutoVariableKeyShare::pack(Archive::ByteStream & target) const
{
for(unsigned int i = 0; i < KeyShareConstants::keyLength; ++i)
for (unsigned int i = 0; i < KeyShareConstants::keyLength; ++i)
Archive::put(target, value.value[i]);
}
//-----------------------------------------------------------------------
void AutoVariableKeyShare::unpack(Archive::ReadIterator & source)
void AutoVariableKeyShare::unpack(Archive::ReadIterator & source)
{
for(unsigned int i = 0; i < KeyShareConstants::keyLength; ++i)
for (unsigned int i = 0; i < KeyShareConstants::keyLength; ++i)
Archive::get(source, value.value[i]);
}
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
File diff suppressed because it is too large Load Diff
@@ -62,7 +62,7 @@ namespace Crafting
namespace Archive
{
// struct DefaultObjectType;
// struct DefaultObjectType;
template <typename T, typename U> class AutoDeltaVector;
}
@@ -71,12 +71,10 @@ typedef Unicode::String String_t;
typedef stdvector <String_t>::fwd StringVector_t;
typedef stdvector<ObjectMenuRequestData>::fwd MenuDataVector;
//========================================================================
// C<->Java conversion functions
//========================================================================
namespace ScriptConversion
{
const bool convert(const Location & sourceLoc, LocalRefPtr & target);
@@ -127,14 +125,13 @@ namespace ScriptConversion
const bool convert(const LocalRefParam & sourceVector, Vector & target);
}
//========================================================================
// class JavaLibrary
//========================================================================
class JavaLibrary
{
// friend jobject convertDynamicVariableListToObject(JNIEnv *env, const DynamicVariableList& list);
// friend jobject convertDynamicVariableListToObject(JNIEnv *env, const DynamicVariableList& list);
friend const bool ScriptConversion::convert(const Location & sourceLoc, LocalRefPtr & target);
friend const bool ScriptConversion::convert(const LocalRefParam & sourceLoc, Location & target);
friend const bool ScriptConversion::convert(const LocalObjectArrayRefParam & sourceLoc, stdvector<Location>::fwd & target);
@@ -239,7 +236,7 @@ public:
static jlong getFreeJavaMemory();
static void printJavaStack();
static ServerObject * findObjectByNetworkId (const NetworkId & id);
static ServerObject * findObjectByNetworkId(const NetworkId & id);
static CreatureObject *getCreatureThrow(JNIEnv *env, jlong objId, char const *errorDescription, bool throwIfNotOnServer = true);
static ShipObject * getShipThrow(JNIEnv *env, jlong objId, char const *errorDescription, bool throwIfNotOnServer = true);
@@ -250,7 +247,7 @@ public:
if (obj != 0)
{
NetworkId id(getNetworkId(obj));
result = dynamic_cast<OBJPTR>(findObjectByNetworkId (id));
result = dynamic_cast<OBJPTR>(findObjectByNetworkId(id));
return result != 0;
}
return 0;
@@ -262,7 +259,7 @@ public:
if (obj != 0)
{
NetworkId id(static_cast<NetworkId::NetworkIdType>(obj));
result = dynamic_cast<OBJPTR>(findObjectByNetworkId (id));
result = dynamic_cast<OBJPTR>(findObjectByNetworkId(id));
return result != 0;
}
return 0;
@@ -274,7 +271,7 @@ public:
if (obj.getValue() != 0)
{
NetworkId id(getNetworkId(obj));
result = dynamic_cast<OBJPTR>(findObjectByNetworkId (id));
result = dynamic_cast<OBJPTR>(findObjectByNetworkId(id));
return result != 0;
}
return 0;
@@ -283,7 +280,7 @@ public:
template <class OBJPTR, class CTLPTR>
static bool getObjectController(const jobject obj, OBJPTR &object, CTLPTR &controller)
{
if (getObject (obj, object) && object)
if (getObject(obj, object) && object)
{
controller = dynamic_cast<CTLPTR>(object->getController());
return controller != 0;
@@ -294,7 +291,7 @@ public:
template <class OBJPTR, class CTLPTR>
static bool getObjectController(const jlong obj, OBJPTR &object, CTLPTR &controller)
{
if (getObject (obj, object) && object)
if (getObject(obj, object) && object)
{
controller = dynamic_cast<CTLPTR>(object->getController());
return controller != 0;
@@ -341,7 +338,7 @@ public:
static void setupWeaponCombatData(JNIEnv *env, const WeaponObject * weapon, jobject weaponData);
static LocalRefPtr createObjectAttribute(const ManufactureObjectInterface & manfSchematic, const DraftSchematicObject & draftSchematic, int attribIndex);
static LocalRefPtr createExperimentAttribute(const ManufactureObjectInterface & manfSchematic, const StringId & attribName);
static LocalRefPtr createExperimentAttribute(const ManufactureObjectInterface & manfSchematic, const StringId & attribName);
static LocalRefPtr convert(const ManufactureObjectInterface & source);
static LocalRefPtr convert(const ManufactureObjectInterface & schematic, const Crafting::IngredientSlot & source, int amountRequired, const std::string & appearance, const std::string & requiredIngredient);
static jobject convert(const DraftSchematicObject & source);
@@ -355,7 +352,7 @@ public:
static jmethodID getMidAttribute();
static jfieldID getFidAttributeType();
static jfieldID getFidAttributeValue();
static jclass getClsBaseClassRangeInfo();
static jfieldID getFidBaseClassRangeInfoMinRange();
static jfieldID getFidBaseClassRangeInfoMaxRange();
@@ -375,9 +372,9 @@ public:
static jfieldID getFidBaseClassDefenderResultsResult();
static jfieldID getFidBaseClassDefenderResultsClientEffectId();
static jclass getClsColor();
static jclass getClsColor();
static jmethodID getMidColor();
static jfieldID getFidCombatEngineAttackerDataWeaponSkill();
static jfieldID getFidCombatEngineAttackerDataAims();
static jfieldID getFidCombatEngineCombatantDataPos();
@@ -539,7 +536,7 @@ public:
static jclass getClsVector();
static jclass getClsVectorArray();
protected:
JavaLibrary(void);
virtual ~JavaLibrary();
@@ -655,7 +652,6 @@ private:
static jclass ms_clsThread; // reference to java.lang.Thread
static jmethodID ms_midThreadDumpStack; // reference to java.lang.Thread.dumpStack()
static jclass ms_clsInternalScriptError; // reference to internal_script_exception
static jclass ms_clsInternalScriptSeriousError; // reference to internal_script_error
static jfieldID ms_fidInternalScriptSeriousErrorError; // fieldID for internal_script_error.wrappedError
@@ -908,7 +904,7 @@ private:
static jfieldID ms_fidCombatEngineWeaponDataElementalType;
static jfieldID ms_fidCombatEngineWeaponDataElementalValue;
static jfieldID ms_fidCombatEngineWeaponDataAttackSpeed;
static jfieldID ms_fidCombatEngineWeaponDataWoundChance;
static jfieldID ms_fidCombatEngineWeaponDataWoundChance;
static jfieldID ms_fidCombatEngineWeaponDataAccuracy;
static jfieldID ms_fidCombatEngineWeaponDataMinRange;
static jfieldID ms_fidCombatEngineWeaponDataMaxRange;
@@ -967,25 +963,25 @@ private:
static jclass ms_clsLibrarySpaceTransition;
static jmethodID ms_midLibrarySpaceTransitionSetPlayerOvert;
static jmethodID ms_midLibrarySpaceTransitionClearOvertStatus;
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// java classes/methods needed by CS Handlers. These classes may not be CS specific
// if there is no previous call into them specifically.
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// java classes/methods needed by CS Handlers. These classes may not be CS specific
// if there is no previous call into them specifically.
static jclass ms_clsLibraryDump;
static jmethodID ms_midLibraryDumpDumpTargetInfo;
static jclass ms_clsLibraryGMLib;
static jmethodID ms_midLibraryGMLibFreeze;
static jmethodID ms_midLibraryGMLibUnfreeze;
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// flag that the JVM was loaded; once it is, it can never be loaded again
// without restarting the program
static int ms_loaded;
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// flag that the JVM was loaded; once it is, it can never be loaded again
// without restarting the program
volatile static int ms_loaded;
static Semaphore * ms_shutdownJava;
// Java initialization functions
@@ -1001,7 +997,7 @@ private:
static jstring callScriptConsoleHandlerEntry(const JavaStringParam & script, const JavaStringParam & method, jobjectArray params);
// obj_id functions
public:
public:
static LocalRefPtr getObjId(const ServerObject & object);
static LocalRefPtr getObjId(const NetworkId::NetworkIdType & id);
static LocalRefPtr getObjId(const NetworkId & id);
@@ -1011,20 +1007,20 @@ private:
static LocalRefPtr getVector(Vector const & vector);
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
static void spaceMakeOvert(const NetworkId &player);
static void spaceClearOvert(const NetworkId &ship);
static std::string getObjectDumpInfo( NetworkId id );
static std::string getObjectDumpInfo(NetworkId id);
static void freezePlayer( const NetworkId &id );
static void unFreezePlayer( const NetworkId &id );
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
static void freezePlayer(const NetworkId &id);
static void unFreezePlayer(const NetworkId &id);
private:
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
private:
// misc support functions
static LocalObjectArrayRefPtr convert(const NetworkId & caller, const std::string& argList, const ScriptParams &args);
@@ -1260,7 +1256,7 @@ inline jfieldID JavaLibrary::getFidBaseClassDefenderResultsId()
{
return ms_fidBaseClassDefenderResultsId;
}
inline jfieldID JavaLibrary::getFidBaseClassDefenderResultsPosture()
{
return ms_fidBaseClassDefenderResultsPosture;
@@ -1330,7 +1326,7 @@ inline jfieldID JavaLibrary::getFidCombatEngineCombatantDataScriptMod()
{
return ms_fidCombatEngineCombatantDataScriptMod;
}
inline jfieldID JavaLibrary::getFidCombatEngineDefenderDataCombatSkeleton()
{
return ms_fidCombatEngineDefenderDataCombatSkeleton;
@@ -1620,7 +1616,7 @@ inline jmethodID JavaLibrary::getMidDynamicVariableListSetFloatArray()
{
return ms_midDynamicVariableListSetFloatArray;
}
inline jmethodID JavaLibrary::getMidDynamicVariableListSetInt()
{
return ms_midDynamicVariableListSetInt;
@@ -1685,7 +1681,7 @@ inline jmethodID JavaLibrary::getMidDynamicVariableListSetVector()
{
return ms_midDynamicVariableListSetVector;
}
inline jmethodID JavaLibrary::getMidDynamicVariableListSetVectorArray()
{
return ms_midDynamicVariableListSetVectorArray;
@@ -1880,7 +1876,7 @@ inline jclass JavaLibrary::getClsRegion()
{
return ms_clsRegion;
}
inline jclass JavaLibrary::getClsResourceAttribute()
{
return ms_clsResourceAttribute;