Exemple #1
0
void GameTryGetUser(session_node *s)
{
   char *ptr;

   if (0 && s->account->type == ACCOUNT_GUEST) /* let guests choose too */
   {
      GameStartUser(s,GetFirstUserByAccountID(s->account->account_id));
   }
   else
   {
      AddByteToPacket(BP_CHARACTERS);
      AddShortToPacket((short)CountUserByAccountID(s->account->account_id));
      ForEachUserByAccountID(GameSendEachUserChoice,s->account->account_id);
      AddStringToPacket(GetMotdLength(),GetMotd());

      /* advertising stuff */
      AddByteToPacket(2);

      ptr = LockConfigStr(ADVERTISE_FILE1);
      AddStringToPacket(strlen(ptr),ptr);
      UnlockConfigStr();
      ptr = LockConfigStr(ADVERTISE_URL1);
      AddStringToPacket(strlen(ptr),ptr);
      UnlockConfigStr();
      ptr = LockConfigStr(ADVERTISE_FILE2);
      AddStringToPacket(strlen(ptr),ptr);
      UnlockConfigStr();
      ptr = LockConfigStr(ADVERTISE_URL2);
      AddStringToPacket(strlen(ptr),ptr);
      UnlockConfigStr();
      
      SendPacket(s->session_id);   
   }
}
Exemple #2
0
void GameSendEachUserChoice(user_node *u)
{
   val_type name_val,num_val;
   resource_node *r;
   
   AddIntToPacket(u->object_id);

   name_val.int_val = SendTopLevelBlakodMessage(u->object_id,USER_NAME_MSG,0,NULL);
   if (name_val.v.tag != TAG_RESOURCE)
   {
      eprintf("GameSendEachUserChoice object %i has non-resource name %i,%i\n",
	      u->object_id,name_val.v.tag,name_val.v.data);
      AddStringToPacket(0,"");
   }
   else
   {
      r = GetResourceByID(name_val.v.data);
      if (r == NULL)
      {
	 bprintf("GameSendEachUserChoice can't find resource %i as a resource/string\n",
		 name_val.v.data);
	    return;
      }
      AddStringToPacket(strlen(r->resource_val),r->resource_val);
   }

   num_val.int_val = SendTopLevelBlakodMessage(u->object_id,IS_FIRST_TIME_MSG,0,NULL);
   if (num_val.v.data != 0)
      AddByteToPacket(1);   /* char has been in game before */
   else
      AddByteToPacket(0);   /* char has NOT been in game before */
      
}
Exemple #3
0
void AddBlakodToPacket(val_type obj_size,val_type obj_data)
{
   int num_bytes;
   char byte1;
   short byte2;
   int byte4;
   string_node *snod;
   resource_node *r;
   val_type temp_val;

   if (obj_size.v.tag != TAG_INT)
   {
      bprintf("AddBlakodToPacket looking for int, # of bytes, got %i,%i\n",
	      obj_size.v.tag,obj_size.v.data);
      return;
   }

   num_bytes = obj_size.v.data;

   if (obj_data.v.tag == TAG_NIL)
      bprintf("AddBlakodToPacket looking for value, got NIL\n");

/*   dprintf("Send %i bytes from %i,%i\n",obj_size.data,obj_data.v.tag,obj_data.v.data); */
   switch (obj_data.v.tag)
   {
   case TAG_STRING :
      snod = GetStringByID(obj_data.v.data);
      if (snod == NULL)
      {
			bprintf("AddBlakodToPacket can't find string id %i\n",obj_data.v.data);
			break;
      }
      AddStringToPacket(snod->len_data,snod->data);
      break;
      
   case TAG_TEMP_STRING :
      snod = GetTempString();
      AddStringToPacket(snod->len_data,snod->data);
      break;

   default :
      switch (num_bytes)
      {
      case 1 :
			byte1 = (char) obj_data.v.data;
			AddByteToPacket(byte1);
			break;
      case 2 : 
			byte2 = (short) obj_data.v.data;
			AddShortToPacket(byte2);
			break;
      case 4 : 
			byte4 = (int) obj_data.v.data;
			AddIntToPacket(byte4);
			break;
      case NUMBER_OBJECT :
			temp_val.int_val = obj_data.int_val;
			temp_val.v.tag = CLIENT_TAG_NUMBER;
			byte4 = temp_val.int_val;
			AddIntToPacket(byte4);
			break;
      case STRING_RESOURCE :
			if (obj_data.v.tag != TAG_RESOURCE)
			{
				bprintf("AddBlakodToPacket can't send %i,%i as a resource/string\n",
						  obj_data.v.tag,obj_data.v.data);
				return;
			}
			r = GetResourceByID(obj_data.v.data);
			if (r == NULL)
			{
				bprintf("AddBlakodToPacket can't find resource %i as a resource/string\n",
						  obj_data.v.data);
				return;
			}
			AddStringToPacket(strlen(r->resource_val[0]),r->resource_val[0]);
			break;
      default :
			bprintf("AddBlakodToPacket can't send %i bytes\n",num_bytes);
			break;
      }
   }
}