コード例 #1
0
ファイル: game.c プロジェクト: AlleyCat1976/Meridian59_103
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);   
   }
}
コード例 #2
0
ファイル: commcli.c プロジェクト: jboullion/Meridian59
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;
      }
   }
}