void BuddyListNamesPacket::parseContent(char *buf, int length, int numberOfAtts) {
    int index = 0;
    // friends
    VariableValue friends;
    index += friends.readName(buf,index);
    index ++; // Ignore 04

    usernames = new vector<string>;
    index = readStrings(usernames,buf,index);

    index += friends.readName(buf,index);
    index ++; // Ignore 04

    nicks = new vector<string>;
    index = readStrings(nicks,buf,index);

    index += friends.readName(buf,index);
    index ++; // Ignore 04
    index += friends.readValue(buf,index);
    userids = new vector<long>;
    int numberOfIds = friends.getValueAsLong();
    for(int i = 0 ; i < numberOfIds ; i++) {
      index += friends.readValue(buf,index,4);
      userids->push_back(friends.getValueAsLong());
      XDEBUG2( "UserID: %ld\n", friends.getValueAsLong() );
    }
  }
Exemple #2
0
void
Exodus::outputScalarVariables()
{
  // List of desired scalar outputs
  const std::set<std::string> & out = getScalarOutput();

  // Append the scalar to the global output lists
  for (const auto & out_name : out)
  {
    // Make sure scalar values are in sync with the solution vector
    // and are visible on this processor.  See TableOutput.C for
    // TableOutput::outputScalarVariables() explanatory comments

    MooseVariableScalar & scalar_var = _problem_ptr->getScalarVariable(0, out_name);
    scalar_var.reinit();
    VariableValue value = scalar_var.sln();

    const std::vector<dof_id_type> & dof_indices = scalar_var.dofIndices();
    const unsigned int n = dof_indices.size();
    value.resize(n);

    const DofMap & dof_map = scalar_var.sys().dofMap();
    for (unsigned int i = 0; i != n; ++i)
    {
      const processor_id_type pid = dof_map.dof_owner(dof_indices[i]);
      this->comm().broadcast(value[i], pid);
    }

    // If the scalar has a single component, output the name directly
    if (n == 1)
    {
      _global_names.push_back(out_name);
      _global_values.push_back(value[0]);
    }

    // If the scalar as many components add indices to the end of the name
    else
    {
      for (unsigned int i = 0; i < n; ++i)
      {
        std::ostringstream os;
        os << out_name << "_" << i;
        _global_names.push_back(os.str());
        _global_values.push_back(value[i]);
      }
    }
  }
}
Exemple #3
0
  int ClientLoginPacket::getPacketContent(char *packet) {
	int index = 0;
 	/*Username*/

	index = XFireUtils::addAttributName(packet,index, "name");/*add username attribute*/
	packet[index] = 0x01;
	packet[index+1] = (char)name.length();
	packet[index+2] = 0x00;
	index +=3;
	std::copy(name.begin(),name.end(),packet+index);
	index += name.size();

	/*Crypted Password*/
	unsigned char pass[41];
	pass[40] = 0x00;
	cryptPassword(pass);
	index = XFireUtils::addAttributName(packet,index, "password");/*add username attribute*/
	packet[index] = 0x01;
	packet[index+1] = (char)40;
	packet[index+2] = 0x00;
	index += 3;

	memcpy(packet+index,pass,40);
	index += 40;

	VariableValue val;
	val.setName( "flags" );
	index += val.writeName( packet, index );
	packet[index++] = 0x02;
	packet[index++] = 0x00;
	packet[index++] = 0x00;
	packet[index++] = 0x00;
	packet[index++] = 0x00;

	val.setName( "sid" );
	index += val.writeName( packet, index );
	packet[index++] = 0x03;

	for(int i=0;i<16;i++)
	{
		packet[index++] = 0x0;
	}

	length = index;
	return index;
  }
  int SendKeepAlivePacket::getPacketContent(char *buf) {
    int index = 0;

    VariableValue val;
    val.setName("value");

    index += val.writeName(buf,index);
    buf[index++] = 2;
    buf[index++] = 0;
    buf[index++] = 0;
    buf[index++] = 0;
    buf[index++] = 0;

    val.setName("stats");

    index += val.writeName(buf,index);
    buf[index++] = 4;
    buf[index++] = 2;
    buf[index++] = 0;
    buf[index++] = 0;

    return index;
  }
Exemple #5
0
// Set variable value
bool VariableValue::set(VariableValue newValue)
{
	if (type_ == VariableValue::BooleanType) valueB_ = newValue.asBool();
	else if (type_ == VariableValue::IntegerType) valueI_ = newValue.asInt();
	else if (type_ == VariableValue::DoubleType) valueD_ = newValue.asDouble();
	else if (type_ == VariableValue::CharType) valueC_ = newValue.asChar();
	else if (type_ == VariableValue::IntegerArrayType) arrayI_ = newValue.asIntArray();
	else if (type_ == VariableValue::DoubleArrayType) arrayD_ = newValue.asDoubleArray();
}
  void ClanBuddyListNamesPacket::parseContent(char *buf, int length, int numberOfAtts) {
    int index = 0;

	VariableValue friends;

	XDEBUG2( "Len: %ld\n", length );

	index+=2; //paar bytes überspringen

	index += friends.readValue(buf,index,2);
	this->clanid = friends.getValueAsLong();

	index+=4; //paar bytes überspringen

    userids = new vector<long>;

	index += friends.readValue(buf,index);
   
	int numberOfIds = friends.getValueAsLong();

	XDEBUG2( "numberofId: %ld\n", numberOfIds );

    for(int i = 0 ; i < numberOfIds ; i++) {
      index += friends.readValue(buf,index,4);
      userids->push_back(friends.getValueAsLong());
      XDEBUG3( "UserID: %ld %ld\n",i+1, friends.getValueAsLong() );
    }

	XDEBUG2( "NextByte: %ld\n",buf[index] );
	XDEBUG2( "NextByte: %ld\n",buf[index+1] );

	index+=3; //nächsten 3 skippen

	XDEBUG2( "NextByte: %ld\n",buf[index] );
	XDEBUG2( "NextByte: %ld\n",buf[index+1] );
	
	usernames = new vector<string>;
    index = readStrings(usernames,buf,index);

	index+=3; //nächsten 3 skippen

	nicks = new vector<string>;
    index = readStrings(nicks,buf,index);

  }
  void XFireClanPacket::parseContent(char *buf, int nlength, int numberOfAtts) {
    VariableValue val;
	int index = 0;
	int length = 0;
	string stringvalue;

	index += 3; // ersten 5 bytes skippen

	this->count=(char)buf[index];

	index += 2;

	for(int i=0;i<this->count;i++)
	{
		index += val.readValue(buf,index,2); //clanid lesen
		this->clanid[i] = val.getValueAsLong();
		index += 2;
	}

	index += 5; // 7 bytes skippen

	for(int i=0;i<this->count;i++)
	{
		length = (unsigned char)buf[index++]; //clannamen lesen
		index++;
		index += val.readValue(buf,index,length);
		stringvalue = string(val.getValue(),length);

		this->name[i] = stringvalue;
	}

	index += 5; // 5 skippen

	for(int i=0;i<this->count;i++)
	{
		length = (unsigned char)buf[index++]; //url anhängsel auslesen
		index++;
		index += val.readValue(buf,index,length);
		stringvalue = string(val.getValue(),length);

		this->url[i] = stringvalue;
	}

  }
  void BuddyListOnlinePacket::parseContent(char *buf, int length, int numberOfAtts) {
	DUMPPACKET("BuddyListOnlinePacket")
    XINFO(( "Got List of buddys that are online\n" ));
    int index = 0;
    // friends
    VariableValue userid;
    userids = new vector<long>;

    /* auskommentiert, wird nicht mehr gesendet 2.3.11
	index += userid.readName(buf,index);
	*/
	index ++; // Ignore 01
    index ++; // Ignore 04
    index ++; // Ignore 02
	

    int numberOfIds = (unsigned char)buf[index];
    index++;
    index++;//ignore 00
    for(int i = 0 ; i < numberOfIds ; i++) {
      index += userid.readValue(buf,index,4);
      userids->push_back(userid.getValueAsLong());
      XINFO2( "UserID: %ld\n", userid.getValueAsLong() );
    }

    VariableValue sid;
    sids = new vector<char *>;
    /* auskommentiert, wird nicht mehr gesendet 2.3.11
	index += sid.readName(buf,index); */

	index ++; // Ignore 03
    index ++; // Ignore 04
    index ++; // Ignore 03
	

    numberOfIds = (unsigned char)buf[index];
    index++;
    index++;//ignore 00
    for(int i = 0 ; i < numberOfIds ; i++) {
      index += userid.readValue(buf,index,16);
      char *sid = new char[16];
      memcpy(sid,userid.getValue(),16);
      sids->push_back(sid);
      //for(int loop = 0; loop < userid.getValueLength();loop++){
      //      XINFO(( "SID: %d\n", userid.getValue()[loop] ));
      //}
    }

  }
 int ClanBuddyListNamesPacket::readStrings(vector<string> *strings, char *buf, int index) {
   VariableValue friends;
   index += friends.readValue(buf,index,2);
   //index ++; // Ignore 00
   int numberOfStrings = friends.getValueAsLong();
   XDEBUG3( "name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings );
   for(int i = 0 ; i < numberOfStrings ; i++) {
     int length = (unsigned char)buf[index++];
     index++;
     index += friends.readValue(buf,index,length);
     string stringvalue = string(friends.getValue(),length);
     strings->push_back(stringvalue);
     XDEBUG(( "String length: %2d : %s\n", length, stringvalue.c_str() ));
   }
   return index;
 }
  int XFireFoundBuddys::readStrings(vector<string> *strings, char *buf, int index) {
    VariableValue friends;
	index+=friends.readName(buf,index);
    index ++; // Ignore 04
	index ++; // Ignore 01

	index+=friends.readValue(buf,index,2);

    int numberOfStrings = friends.getValueAsLong();
    XDEBUG3( "name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings );
    for(int i = 0 ; i < numberOfStrings ; i++) {
		XDEBUG2( "Index: %ld\n", index );
      int length = (unsigned char)buf[index++];
      index++;
      index += friends.readValue(buf,index,length);
      string stringvalue = string(friends.getValue(),length);
      strings->push_back(stringvalue);
      XDEBUG3( "String length: %2d : %s\n", length, stringvalue.c_str() );
    }
    return index;
  }
  void LoginSuccessPacket::parseContent(char *buf, int length, int numberOfAtts) {

    int read = 0;
    for(int i = 0 ; i < numberOfAtts ; i++) {
      VariableValue *val = new VariableValue();
      read += val->readName(buf, read);
      XDEBUG(( "Read Variable Name: %s\n", val->getName().c_str() ));
      if (val->getName() == "userid") {
	read++; // ignore 02
	read += val->readValue(buf, read, 3);
	read++; // ignore 00
	XDEBUG2( "My userid: %lu\n", val->getValueAsLong() );
	this->myuid=val->getValueAsLong();
      } else if (val->getName() == "sid") {
	read++; // ignore 03
	read+=val->readValue(buf, read, 16);
	//XDEBUG(( "My SID: %u\n", val->getValue() ));
      } else if (val->getName() == "nick") {
	//int lengthLength = (int)val->getValueAsLong();
	read++; // ignore 01
	//read+=val->readValue(buf, read, -1, 1);

	unsigned int l = (unsigned char)buf[read++];  //dufte - nick wird benötigt
	XDEBUG2( "Nick Length: %d\n", l );
    read++;
    read += val->readValue(buf,read,l);
	XDEBUG2( "Nick Length: %s\n", val->getValue() );

	this->nick=std::string(val->getValue(),l);

      } else if (val->getName() == "status") {
	read+=5; // ignore everything
      } else if (val->getName() == "dlset") {
	read+=3; // ignore everything
      } else {
	i = numberOfAtts; 
	// If we find something we don't know .. we stop parsing the 
	// packet.. who cares about the rest...
      }
      delete val;
    }
  }
  int SendMessagePacket::getPacketContent(char *buf) {
    if ( imindex == 0 ) initIMIndex();

    int index = 0;
    VariableValue val;
    val.setName("sid");
    val.setValue(sid,16);

    index += val.writeName(buf,index);
    buf[index++] = 3;
    index += val.writeValue(buf,index);

    val.setName("peermsg");
    index += val.writeName(buf,index);
    buf[index++] = 5;
    //buf[index++] = 7;
    buf[index++] = 3;

    val.setName("msgtype");
    val.setValueFromLong(0,4);
    index += val.writeName(buf,index);
    buf[index++] = 2;
    index += val.writeValue(buf,index);

    val.setName("imindex");
    val.setValueFromLong(imindex,4);
    index += val.writeName(buf,index);
    buf[index++] = 02;
    index += val.writeValue(buf,index);

    val.setName("im");
    val.setValue((char*)message.c_str(),message.size());
    index += val.writeName(buf,index);
    buf[index++] = 01;
    buf[index++] = message.size()%256;
    buf[index++] = (int)message.size()/256;
    index += val.writeValue(buf,index);

    return index;
  }
VariableValue::VariableValue (const VariableValue& other)
	: m_variable(other.m_variable)
	, m_storage(other.m_variable->getType())
{
	m_storage.getValue(getType()) = other.getValue().value();
}
  int SendGameStatus2Packet::getPacketContent(char *buf) {
	
    VariableValue val;

    val.setName( getGameAttributeName() );

    val.setValueFromLong(gameid,4);
    
    int index = 0;
    index += val.writeName(buf, index);
    buf[index++] = 02;
    index += val.writeValue(buf, index);

    val.setName( getIPAttributeName() );

	//BUG: hab ,4 hinzugefügt, führte und vista zum crash - dufte
    val.setValue(ip,4);
    val.setValueLength(4);

    index += val.writeName(buf, index);
    buf[index++] = 02;
    index += val.writeValue(buf, index);
    val.setName( getPortAttributeName() );
    val.setValueFromLong(port,4);
    index += val.writeName(buf, index);
    buf[index++] = 02;
    index += val.writeValue(buf, index);

    return index;
  }