Exemplo n.º 1
0
void CFilterATMApp::WriteScriptParameters(PIWriteDescriptor token)
   {
   PutInteger(token, keyRadius, m_sData->nRadius);
   PutInteger(token, keyAlpha, m_sData->nAlpha);
   if(m_sData->bKeepNoise)
      PutBoolean(token, keyKeepNoise, m_sData->bKeepNoise);
   }
Exemplo n.º 2
0
void GeneratorTest()
{
    char* string;
    JsonObject* root = CreateJsonObject();
    JsonObject* element = CreateJsonObject();
    JsonArray* array = CreateJsonArray();
    AddInteger(array, 0);
    AddReal(array, 0.0);
    AddBoolean(array, FALSE);
    AddObject(array, element);
    AddString(array, "element");
    AddNull(array);
    PutNull(root, "0");
    PutInteger(root, "Year", 1970);
    PutInteger(root, "Month", 3);
    PutInteger(root, "Date", 18);
    PutArray(root, "Array", array);
    PutBoolean(root, "Proposition", TRUE);
    PutString(root, "Text", "Hello World");
    PutReal(root, "Pi", 3.14159265358979323846264338327950288419716939937510582097494459230781640);
    string = ToString(root);
    printf("%s", string);
    printf("\r\n");
    EXPECT_EQUAL_STRING("{\"0\":null,\"Year\":1970,\"Month\":3,\"Date\":18,\"Array\":[0,0.000000,false,{},\"element\",null],\"Proposition\":true,\"Text\":\"Hello World\",\"Pi\":3.141593}", string);
    free(string);
    ClearJsonObject(root);
    ClearJsonArray(array);
    string = ToString(root);
    EXPECT_EQUAL_STRING("{}", string);
    free(string);
}
Exemplo n.º 3
0
int PartyManager :: WriteMemberList(char *outbuf, ActiveParty *party, int memberID)
{
	//memberID is the creature ID that is requesting the list.
	//The client needs this to determine if it's leading the party.
	int wpos = 0;
	wpos += PutByte(&outbuf[wpos], 6);     //_handlePartyUpdateMsg
	wpos += PutShort(&outbuf[wpos], 0);

	wpos += PutByte(&outbuf[wpos], PartyUpdateOpTypes::JOINED_PARTY);

	//wpos += PutByte(&outbuf[wpos], party->mMemberList.size());
	int countLoc = wpos;
	wpos += PutByte(&outbuf[wpos], 0);
	wpos += PutInteger(&outbuf[wpos], party->mLeaderID);
	wpos += PutInteger(&outbuf[wpos], memberID);  //memberId

	int count = 0;
	for(size_t i = 0; i < party->mMemberList.size(); i++)
	{
		if(party->mMemberList[i].mCreatureID != memberID)
		{
			wpos += PutInteger(&outbuf[wpos], party->mMemberList[i].mCreatureID);
			wpos += PutStringUTF(&outbuf[wpos], party->mMemberList[i].mDisplayName.c_str());
			count++;
		}
	}
	PutByte(&outbuf[countLoc], count);
	PutShort(&outbuf[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 4
0
void CAutomateGraphingApp::WriteScriptParameters(PIActionDescriptor descriptor)
   {
   // files with system parameters (input) and results (output)
   PutString(descriptor, keyParameters, m_sData->sParameters);
   PutString(descriptor, keyResults, m_sData->sResults);
   // system options
   if(m_sData->bJpeg)
      PutBoolean(descriptor, keyJpeg, m_sData->bJpeg);
   if(m_sData->bPresetStrength)
      PutBoolean(descriptor, keyPresetStrength, m_sData->bPresetStrength);
   // range of embedding strengths
   PutFloat(descriptor, keyStrengthMin, m_sData->dStrengthMin);
   PutFloat(descriptor, keyStrengthMax, m_sData->dStrengthMax);
   PutFloat(descriptor, keyStrengthStep, m_sData->dStrengthStep);
   // range of JPEG compression quality (if requested)
   if(m_sData->bJpeg)
      {
      PutInteger(descriptor, keyJpegMin, m_sData->nJpegMin);
      PutInteger(descriptor, keyJpegMax, m_sData->nJpegMax);
      PutInteger(descriptor, keyJpegStep, m_sData->nJpegStep);
      }
   // requested outputs
   PutBoolean(descriptor, keyPrintBER, m_sData->bPrintBER);
   PutBoolean(descriptor, keyPrintSNR, m_sData->bPrintSNR);
   PutBoolean(descriptor, keyPrintEstimate, m_sData->bPrintEstimate);
   PutBoolean(descriptor, keyPrintChiSquare, m_sData->bPrintChiSquare);
   }
Exemplo n.º 5
0
int PrepExt_SendBookOpen(char *buffer, int bookID, int page) {
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 96);              //_handleBooks
	wpos += PutShort(&buffer[wpos], 0);             //Placeholder for message size
	wpos += PutByte(&buffer[wpos], 1); 				// Open
	wpos += PutInteger(&buffer[wpos], bookID);
	wpos += PutInteger(&buffer[wpos], page);
	PutShort(&buffer[1], wpos - 3);                 //Message size
	return wpos;
}
Exemplo n.º 6
0
int PrepExt_ChangeTarget(char *buffer, int sourceID, int targetID)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 4);  //_handleCreatureEventMsg
	wpos += PutShort(&buffer[wpos], 0);

	wpos += PutInteger(&buffer[wpos], sourceID);
	wpos += PutByte(&buffer[wpos], 5);     //5 = Entity's target changed
	wpos += PutInteger(&buffer[wpos], targetID);

	PutShort(&buffer[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 7
0
int PrepExt_TradeCurrencyOffer(char *buffer, int offeringPlayerID, int tradeAmount)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 51);     //_handleTradeMsg
	wpos += PutShort(&buffer[wpos], 0);     //Placeholder for size
	wpos += PutInteger(&buffer[wpos], offeringPlayerID);   //traderID
	wpos += PutByte(&buffer[wpos], TradeEventTypes::CURRENCY_OFFERED);     //eventType
	wpos += PutByte(&buffer[wpos], 1);   //currency types
	wpos += PutByte(&buffer[wpos], CurrencyCategory::COPPER);     //currencies offered
	wpos += PutInteger(&buffer[wpos], tradeAmount);                    //currency amount
	PutShort(&buffer[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 8
0
int PrepExt_CreatureEventVaultSize(char *buffer, int actorID, int vaultSize, int deliverySlots)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 4);  //_handleCreatureEventMsg
	wpos += PutShort(&buffer[wpos], 0);

	wpos += PutInteger(&buffer[wpos], actorID);
	wpos += PutByte(&buffer[wpos], 25);             //event to update vault size

	wpos += PutInteger(&buffer[wpos], vaultSize);
	wpos += PutInteger(&buffer[wpos], deliverySlots);

	PutShort(&buffer[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 9
0
int PrepExt_SendAbilityOwn(char *buffer, int CID, int abilityID, int eventID)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 60);  //_handleAbilityActivationMsg
	wpos += PutShort(&buffer[wpos], 0);

	wpos += PutInteger(&buffer[wpos], CID);   //Creature Instance ID
	wpos += PutShort(&buffer[wpos], abilityID);  //ability ID
	wpos += PutByte(&buffer[wpos], eventID);  //7 = ability ownage
	wpos += PutInteger(&buffer[wpos], 0);   //target_len
	wpos += PutInteger(&buffer[wpos], 0);   //secondary_len
	wpos += PutByte(&buffer[wpos], 0);      //has_ground

	PutShort(&buffer[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 10
0
int TradeOfferHandler::protected_helper_query_trade_offer(SimulatorThread *sim,
		CharacterServerData *pld, SimulatorQuery *query,
		CreatureInstance *creatureInstance) {
	int selfID = creatureInstance->CreatureID;
	int tradeID = creatureInstance->activeLootID;
	ActiveInstance *actInst = creatureInstance->actInst;
	TradeTransaction *tradeData = actInst->tradesys.GetExistingTransaction(
			tradeID);
	if (tradeData == NULL)
		return QueryErrorMsg::TRADENOTFOUND;

	TradePlayerData *pData = tradeData->GetPlayerData(selfID);
	if (pData == NULL)
		return actInst->tradesys.CancelTransaction(selfID, tradeID, sim->SendBuf);

	CreatureInstance *cInst = pData->otherPlayerData->cInst;

	int wpos = 0;
	wpos += PutByte(&sim->SendBuf[wpos], 51);     //_handleTradeMsg
	wpos += PutShort(&sim->SendBuf[wpos], 0);    //Placeholder for size
	wpos += PutInteger(&sim->SendBuf[wpos], creatureInstance->CreatureID);   //traderID
	wpos += PutByte(&sim->SendBuf[wpos], TradeEventTypes::OFFER_MADE);    //eventType
	PutShort(&sim->SendBuf[1], wpos - 3);       //Set message size

	SendToOneSimulator(sim->SendBuf, wpos, cInst->simulatorPtr);
	//actInst->LSendToOneSimulator(SendBuf, wpos, cInst->SimulatorIndex);

	return PrepExt_QueryResponseString(sim->SendBuf, query->ID, "OK");
}
Exemplo n.º 11
0
int RespondPrefGet(PreferenceContainer *prefSet, char *SendBuf,
		SimulatorQuery *query) {
	//Helper function for the "pref.getA" and "pref.get" queries.
	//Since the both accounts and characters use the same class to store
	//preferences, the query handlers will call this function with the
	//appropriate pointer.

	int WritePos = 0;
	WritePos += PutByte(&SendBuf[WritePos], 1);          //_handleQueryResultMsg
	WritePos += PutShort(&SendBuf[WritePos], 0);           //Message size
	WritePos += PutInteger(&SendBuf[WritePos], query->ID); //Query response index

	//Each preference request will have a matching response field.
	WritePos += PutShort(&SendBuf[WritePos], query->argCount);

	for (unsigned int i = 0; i < query->argCount; i++) {
		const char * pref = prefSet->GetPrefValue(query->args[i].c_str());

		//One string for each preference result.
		WritePos += PutByte(&SendBuf[WritePos], 1);
		if (pref != NULL) {
			WritePos += PutStringUTF(&SendBuf[WritePos], pref);
		} else {
			WritePos += PutStringUTF(&SendBuf[WritePos], "");
		}
	}

	PutShort(&SendBuf[1], WritePos - 3);

	return WritePos;
}
Exemplo n.º 12
0
int PrepExt_QueryResponseMultiString(char *buffer, int queryIndex, const MULTISTRING &strData)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 1);              //_handleQueryResultMsg
	wpos += PutShort(&buffer[wpos], 0);             //Placeholder for message size
	wpos += PutInteger(&buffer[wpos], queryIndex);  //Query response index

	size_t rowCount = strData.size();
	size_t stringCount;
	wpos += PutShort(&buffer[wpos], rowCount);
	for(size_t rows = 0; rows < rowCount; rows++)
	{
		stringCount = strData[rows].size();
		if(stringCount > 255)
		{
			g_Logs.server->warn("PrepExt_QueryResponseMultiString too many strings: %v", stringCount);
			stringCount = 255;
		}
		wpos += PutByte(&buffer[wpos], stringCount);
		for(size_t str = 0; str < stringCount; str++)
		{
			//g_Log.AddMessageFormat("[DEBUG] [%d][%d]=%s", rows, str, strData[rows][str].c_str());
			wpos += PutStringUTF(&buffer[wpos], strData[rows][str].c_str());   //String data
		}
	}
	PutShort(&buffer[1], wpos - 3);
	return wpos;
}
Exemplo n.º 13
0
int PartyManager :: WriteProposeInvite(char *outbuf, int proposeeId, const char *proposeeName, int proposerId, const char *proposerName)
{
	int wpos = 0;
	wpos += PutByte(&outbuf[wpos], 6);     //_handlePartyUpdateMsg
	wpos += PutShort(&outbuf[wpos], 0);

	wpos += PutByte(&outbuf[wpos], PartyUpdateOpTypes::PROPOSE_INVITE);
	
	wpos += PutInteger(&outbuf[wpos], proposeeId);
	wpos += PutStringUTF(&outbuf[wpos], proposeeName);

	wpos += PutInteger(&outbuf[wpos], proposerId);
	wpos += PutStringUTF(&outbuf[wpos], proposerName);

	PutShort(&outbuf[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 14
0
int PrepExt_SendHeartbeatMessage(char *buffer, unsigned long elapsedMilliseconds)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 90);   //_handleHeartbeatMessage
	wpos += PutShort(&buffer[wpos], 0);   //Reserve for size
	wpos += PutInteger(&buffer[wpos], elapsedMilliseconds);
	PutShort(&buffer[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 15
0
void CAutomateEmbeddingApp::WriteScriptParameters(PIActionDescriptor descriptor)
   {
   // path for output files
   PutString(descriptor, keyOutput, m_sData->sOutput);
   // system options
   if(m_sData->bJpeg)
      PutBoolean(descriptor, keyJpeg, m_sData->bJpeg);
   // range of embedding strengths
   PutFloat(descriptor, keyStrengthMin, m_sData->dStrengthMin);
   PutFloat(descriptor, keyStrengthMax, m_sData->dStrengthMax);
   PutFloat(descriptor, keyStrengthStep, m_sData->dStrengthStep);
   // range of JPEG compression quality (if requested)
   if(m_sData->bJpeg)
      {
      PutInteger(descriptor, keyJpegMin, m_sData->nJpegMin);
      PutInteger(descriptor, keyJpegMax, m_sData->nJpegMax);
      PutInteger(descriptor, keyJpegStep, m_sData->nJpegStep);
      }
   }
Exemplo n.º 16
0
int PartyManager :: WriteRemoveMember(char *outbuf, int memberID)
{
	int wpos = 0;
	wpos += PutByte(&outbuf[wpos], 6);     //_handlePartyUpdateMsg
	wpos += PutShort(&outbuf[wpos], 0);
	wpos += PutByte(&outbuf[wpos], PartyUpdateOpTypes::REMOVE_MEMBER);
	wpos += PutInteger(&outbuf[wpos], memberID);
	PutShort(&outbuf[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 17
0
int PrepExt_QueryResponseNull(char *buffer, int queryIndex)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 1);              //_handleQueryResultMsg
	wpos += PutShort(&buffer[wpos], 0);             //Placeholder for message size
	wpos += PutInteger(&buffer[wpos], queryIndex);  //Query response index
	wpos += PutShort(&buffer[wpos], 0);             //Row count
	PutShort(&buffer[1], wpos - 3);                 //Message size
	return wpos;
}
Exemplo n.º 18
0
int PrepExt_SendEffect(char *buffer, int sourceID, const char *effectName, int targetID)
{
	//Send an effect to the client.  Send as a single target effect
	//unless targetID is nonzero.

	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 4);       //_handleCreatureEventMsg
	wpos += PutShort(&buffer[wpos], 0);      //Reserve for size

	wpos += PutInteger(&buffer[wpos], sourceID);

	wpos += PutByte(&buffer[wpos], (targetID == 0) ? 4 : 12);  //Cue effect
	wpos += PutStringUTF(&buffer[wpos], effectName);
	if(targetID != 0)
		wpos += PutInteger(&buffer[wpos], targetID);

	PutShort(&buffer[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 19
0
int PartyManager :: WriteInCharge(char *outbuf, ActiveParty *party)
{
	int wpos = 0;
	wpos += PutByte(&outbuf[wpos], 6);     //_handlePartyUpdateMsg
	wpos += PutShort(&outbuf[wpos], 0);
	wpos += PutByte(&outbuf[wpos], PartyUpdateOpTypes::IN_CHARGE);
	wpos += PutInteger(&outbuf[wpos], party->mLeaderID);
	wpos += PutStringUTF(&outbuf[wpos], party->mLeaderName.c_str());
	PutShort(&outbuf[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 20
0
int PartyManager :: WriteQuestInvite(char *outbuf, const char* questName, int questID)
{
	int wpos = 0;
	wpos += PutByte(&outbuf[wpos], 6);     //_handlePartyUpdateMsg
	wpos += PutShort(&outbuf[wpos], 0);
	wpos += PutByte(&outbuf[wpos], PartyUpdateOpTypes::QUEST_INVITE);
	wpos += PutStringUTF(&outbuf[wpos], questName);
	wpos += PutInteger(&outbuf[wpos], questID);
	PutShort(&outbuf[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 21
0
int PrepExt_AbilityEvent(char *buffer, int creatureID, int abilityID, int abilityEvent)
{
	//Same as AbilityActivate, but target lists and ground are always zero.
	//Used for the utility messages such as activation requests.

	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 60);  //_handleAbilityActivationMsg
	wpos += PutShort(&buffer[wpos], 0);

	wpos += PutInteger(&buffer[wpos], creatureID);   //actorID
	wpos += PutShort(&buffer[wpos], abilityID);     //abId
	wpos += PutByte(&buffer[wpos], abilityEvent);      //event

	wpos += PutInteger(&buffer[wpos], 0);   //target_len
	wpos += PutInteger(&buffer[wpos], 0);   //secondary_len
	wpos += PutByte(&buffer[wpos], 0);      //has_ground

	PutShort(&buffer[1], wpos - 3);
	return wpos;
}
Exemplo n.º 22
0
int PrepExt_QueryResponseError(char *buffer, int queryIndex, const char *message)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 1);              //_handleQueryResultMsg
	wpos += PutShort(&buffer[wpos], 0);             //Placeholder for message size
	wpos += PutInteger(&buffer[wpos], queryIndex);  //Query response index
	wpos += PutShort(&buffer[wpos], 0x7000);        //Negative number indicates error
	wpos += PutStringUTF(&buffer[wpos], message);   //String data
	PutShort(&buffer[1], wpos - 3);                 //Message size
	return wpos;
}
Exemplo n.º 23
0
int PartyManager :: StrategyFlagsChange(char *outbuf, int newFlags)
{
	int wpos = 0;
	wpos += PutByte(&outbuf[wpos], 6);     //_handlePartyUpdateMsg
	wpos += PutShort(&outbuf[wpos], 0);

	wpos += PutByte(&outbuf[wpos], PartyUpdateOpTypes::STRATEGYFLAGS_CHANGE);
	wpos += PutInteger(&outbuf[wpos], newFlags);

	PutShort(&outbuf[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 24
0
int PrepExt_SetAvatar(char *buffer, int creatureID)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 0x04);
	wpos += PutShort(&buffer[wpos], 0x00);

	wpos += PutInteger(&buffer[wpos], creatureID);
	wpos += PutByte(&buffer[wpos], 0x01);    //Event to Set Avatar

	PutShort(&buffer[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 25
0
int PrepExt_CancelUseEvent(char *buffer, int CreatureID)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 4);  //_handleCreatureEventMsg
	wpos += PutShort(&buffer[wpos], 0);  //size
	wpos += PutInteger(&buffer[wpos], CreatureID);
	wpos += PutByte(&buffer[wpos], 11);  //creature "used" event
	wpos += PutStringUTF(&buffer[wpos], "");
	wpos += PutFloat(&buffer[wpos], -1.0F);  //A delay of -1 will interrupt the action
	PutShort(&buffer[1], wpos - 3);  //size
	return wpos;
}
Exemplo n.º 26
0
int PrepExt_ActorJump(char *buffer, int actor)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 4);  //_handleCreatureEventMsg
	wpos += PutShort(&buffer[wpos], 0);

	wpos += PutInteger(&buffer[wpos], actor);   //actorID
	wpos += PutByte(&buffer[wpos], 3);     //3 = jump

	PutShort(&buffer[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 27
0
int PrepExt_RemoveCreature(char *buffer, int actorID)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 4);  //_handleCreatureEventMsg
	wpos += PutShort(&buffer[wpos], 0);

	wpos += PutInteger(&buffer[wpos], actorID);   //actorID
	wpos += PutByte(&buffer[wpos], 0);     //0 = remove ID

	PutShort(&buffer[1], wpos - 3);       //Set message size
	return wpos;
}
Exemplo n.º 28
0
int PrepExt_QueryResponseString(char *buffer, int queryIndex, const char *strData)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 1);              //_handleQueryResultMsg
	wpos += PutShort(&buffer[wpos], 0);             //Placeholder for message size
	wpos += PutInteger(&buffer[wpos], queryIndex);  //Query response index
	wpos += PutShort(&buffer[wpos], 1);             //Row count
	wpos += PutByte(&buffer[wpos], 1);              //String count
	wpos += PutStringUTF(&buffer[wpos], strData);   //String data
	PutShort(&buffer[1], wpos - 3);                 //Message size
	return wpos;
}
Exemplo n.º 29
0
int PrepExt_SendFallDamage(char *buffer, int damage)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 0);       //_handleInfoMsg
	wpos += PutShort(&buffer[wpos], 0);      //Placeholder for size

	wpos += PutStringUTF(&buffer[wpos], "");  //Unused?
	wpos += PutByte(&buffer[wpos], 11);       //Event type for fall damage message
	wpos += PutInteger(&buffer[wpos], damage);

	PutShort(&buffer[1], wpos - 3);     //Set size
	return wpos;
}
Exemplo n.º 30
0
int PrepExt_SendEmoteControl(char *buffer, int creatureID, int emoteEvent)
{
	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 100);   //_handleModMessage   REQUIRES MODDED CLIENT
	wpos += PutShort(&buffer[wpos], 0);    //Reserve for size

	wpos += PutByte(&buffer[wpos], MODMESSAGE_EVENT_EMOTE_CONTROL);   //event for advanced emote

	wpos += PutInteger(&buffer[wpos], creatureID);
	wpos += PutByte(&buffer[wpos], emoteEvent);

	PutShort(&buffer[1], wpos - 3);       //Set message size
	return wpos;
}