| Author | 
		Message | 
	
	
		Samapico No, these DO NOT look like penises, ok?
  
   Joined: May 08 2003 Posts: 1252 Offline
  | 
		
			
			  
			    
				
					 Posted: Mon Sep 06, 2010 7:42 pm     Post subject: MERVBot doesn't handle *getfile? | 
					  | 
					      | 
				 
			     
			   | 
			 
			
				
  | 
			 
			
				I'm trying to get a mervbot to *getfile a list of files from the server, in sequence. But when the bot does a *getfile, it 
 
What shows up in the bot's log:
 
 
BOT>Sama  PV:Samapico> !getfilelist somelist.txt
 
BOT>Sama  A:File sent: server.cfg
 
 (please wait...)
 
BOT>Sama  Unknown message type 16(17)
 
 
 
From what I understand, a packet 16 with a length of 17 would be a file transfer packet with no data
 
 
 
What's happening?
 
 
 
Relevant code from the core:
 
	
 
 
void __stdcall handleFileTransfer(hostMessage *m)
 
{   DEFLATE_CLASS
 
 
   /*   Field   Length   Description
 
      0      1      Type byte
 
      1      16      File name
 
      17      ...      [Compressed] file
 
   */
 
 
   char *name = msg + 1;
 
   char *buffer = msg + 17;
 
   Uint32 i, length = len - 17;
 
 
   if (len <= 17)
 
   {
 
      handleUnknown(m);
 
 
      return;
 
   }
 
 
   for (i = 0; i < 16; ++i)
 
   {
 
      char c = name[i];
 
 
      if (c == 0)
 
         break;
 
 
      switch (c)
 
      {
 
      case '/':
 
      case '\\':
 
         h->logEvent("WARNING: Invalid downloaded-file name path ignored. (%s)", name);
 
         return;
 
      };
 
 
      if ((c < ' ') || (c > '~'))
 
      {
 
         h->logEvent("WARNING: Invalid downloaded-file name chars ignored.");
 
         return;
 
      }
 
   }
 
 
   if (i == 16)
 
   {
 
      h->logEvent("WARNING: Unterminated downloaded-file name ignored.");
 
 
      return;
 
   }
 
 
   if (*name)
 
   {   // regular file
 
      String fname = "get/";
 
      fname += name;
 
 
      ofstream file(fname.msg, ios::binary);
 
      if (file)
 
      {
 
         file.write(buffer, length);
 
 
         h->logEvent("Received file: %s", fname.msg);
 
 
         h->imports->talk(makeFile(fname.msg));
 
      }
 
      else
 
      {
 
         h->logEvent("Unable to open file for write: %s", fname.msg);
 
      }
 
   }
 
   else
 
   {   // news file
 
      h->downloadingNews = false;
 
 
      if (decompress_to_file("get/news.txt", buffer, length))
 
         h->logEvent("News file successfully transferred!");
 
      else
 
         h->logEvent("Unable to decompress news file.");
 
   }
 
}
 
  |  
  _________________ (Insert a bunch of dead links here) | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		cycad Novice
  
   Gender:  Joined: Feb 12 2004 Posts: 29 Offline
  | 
		
			
			  
			    
				
					 Posted: Tue Sep 07, 2010 2:32 pm     Post subject:  | 
					  | 
					      | 
				 
			     
			   | 
			 
			
				
  | 
			 
			
				I think file transfer packets are core type 0x0A.  I don't know what type 16 would be, I do S2C file transfers using 0x0A exclusively (which may or may not be correct:).  If you can print the raw packet data received the problem might be more evident.
 
 
Also, is this with subgame or asss? | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		Samapico No, these DO NOT look like penises, ok?
  
   Joined: May 08 2003 Posts: 1252 Offline
  | 
		
			
			  
			    
				
					 Posted: Tue Sep 07, 2010 9:52 pm     Post subject:  | 
					  | 
					      | 
				 
			     
			   | 
			 
			
				
  | 
			 
			
				subgame
 
 
Any easy way to print the raw packet data? Or do I need to recompile the bot entirely?
 
 
 
And... according to the wiki, it's 0x10
 
 
http://wiki.minegoboom.com/index.php/UDP_Game_Protocol
 
 
 
----------------------------------------
 
0x0A	Game	0x40306F	Password response
 
 
[...] 
 
 
----------------------------------------
 
0x10	Game	0x4027CD	File transfer
 
 
-		0	1	Type | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		cycad Novice
  
   Gender:  Joined: Feb 12 2004 Posts: 29 Offline
  | 
		
			
			  
			    
				
					 Posted: Tue Sep 07, 2010 11:54 pm     Post subject:  | 
					  | 
					      | 
				 
			     
			   | 
			 
			
				
  | 
			 
			
				I'm not sure about packet printing, maybe merv has a debug output option somewhere.
 
 
As far as the packet types mine is for the core type (not game) 0x0A, and my handler is http://pastebin.com/nZBxj1ub
 
and I haven't had any problems/complaints.  Maybe there's a difference between lvz file transfers such as when you join an arena and *getfile transfers.  The handler above is for *getfile.
 
 
It's been a while since I looked at the code so I might be missing something. | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		 |