Advertisement
Guest User

PennMUSHBugFix.xml

a guest
Aug 27th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 2.62 KB | None | 0 0
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <!DOCTYPE muclient>
  3.  
  4. <muclient>
  5. <plugin
  6.   name="PennMUSHBugFix"
  7.   author="Sora"
  8.   id="4f3adac0d57648e14e1cdf64"
  9.   language="Lua"
  10.   purpose="Fix the \n lag with pennmush"
  11.   save_state="y"
  12.   date_written="2006-07-07 13:14:43"
  13.   requires="3.70"
  14.   version="1.1"
  15.   >
  16. <description trim="y">
  17. <![CDATA[
  18. PennMUSH unfortunately doesn't always send the end of a line (The newline character) immediately after a line, so triggers in mushclient that modify lines will have lag time before they're applied to the line. This fixes that.
  19.  
  20. Probably don't wanna use this on MUD's, or things that have 'prompts' that never add on a newline to the end.
  21. ]]>
  22. </description>
  23.  
  24. </plugin>
  25.  
  26.  
  27. <!--  Get our standard constants -->
  28.  
  29. <include name="constants.lua"/>
  30.  
  31. <script>
  32. <![CDATA[
  33.  
  34. local oldlength = 0
  35. local state = 0
  36. local oldPacket = ""
  37.  
  38. function OnPluginPacketReceived (packet)
  39.     -- If we got an anti-idle packet, do nothing with it
  40.     if (packet == "\255\241") then return; end
  41.  
  42.     if (state ~= 1 and string.sub(packet,-1) == "\n") then
  43.         packet = oldPacket .. packet
  44.         oldPacket = ""
  45.         state = 0
  46.         if (string.len(packet) > 900) then
  47.             Redraw()
  48.         end
  49.         return packet
  50.     end
  51.    
  52.     local lines = utils.split(oldPacket .. packet,"\n")
  53.  
  54.     if (table.getn(lines) > 1) then
  55.         packet = table.concat(lines,"\n",1,table.getn(lines)-1) .. "\n"
  56.         oldPacket = table.concat(lines,"\n",table.getn(lines))
  57.         state = 3
  58.         if (string.len(packet) > 900) then
  59.             Redraw()
  60.         end
  61.         return packet
  62.     end
  63.    
  64.     local packetcopy = packet;
  65.     local packetlength = string.len(packet);
  66.    
  67.     if (state == 0 and packetlength <= 999) then
  68.         if (string.sub(packet,-1) == "\n") then return packet; end
  69.         oldPacket = packet
  70.         state = 3
  71.         return ""
  72.     elseif (state == 3) then
  73.         if (packet == "\r\n" or (packetlength < 999 and string.sub(packet,-1) == "\n")) then
  74.             packet = oldPacket .. packet
  75.             oldPacket = ""
  76.             state = 0
  77.             if (string.len(packet) > 900) then
  78.                 Redraw()
  79.             end
  80.             return packet
  81.         else
  82.             oldPacket = oldPacket .. packet
  83.             return ""
  84.         end
  85.     end
  86.    
  87.     oldPacket = ""
  88.    
  89.     if (packetlength < 999 and string.sub(packet,-1) ~= "\n" and (oldlength ~= 999 and packetlength ~= 429)) then
  90.         state = 1;
  91.             if (string.len(packet) > 900) then
  92.                 Redraw()
  93.             end
  94.         return packet .. "\r\n";
  95.     end
  96.    
  97.     if (state == 1) then
  98.         state = 0;
  99.         oldlength = 0;
  100.        
  101.         if (packet == "\r\n") then
  102.             return "";
  103.         end
  104.        
  105.         packet = string.gsub(packet,"^\r\n","",1);
  106.     end
  107.    
  108.     oldlength = packetlength;
  109.     if (string.len(packet) > 900) then
  110.         Redraw()
  111.     end
  112.     return packet;
  113. end
  114.  
  115. ]]>
  116. </script>
  117.  
  118. </muclient>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement