User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion

Reply
Thread Tools Display Modes
Unread 7 Oct 2007, 17:47   #1
Clouds
Registered User
 
Clouds's Avatar
 
Join Date: Jan 2004
Location: United Kingdom
Posts: 1,386
Clouds is a splendid one to beholdClouds is a splendid one to beholdClouds is a splendid one to beholdClouds is a splendid one to beholdClouds is a splendid one to beholdClouds is a splendid one to beholdClouds is a splendid one to behold
mIRC code for Planetarion dumps

Anyone got the code for this?
Clouds is offline   Reply With Quote
Unread 7 Oct 2007, 17:49   #2
Marv
Jazz Man
 
Marv's Avatar
 
Join Date: Jan 2003
Posts: 1,494
Marv is a jewel in the roughMarv is a jewel in the roughMarv is a jewel in the rough
Re: mIRC code for Planetarion dumps

Code to do what exactly?

Do you mean to perform a look up on the data at the dump url?
__________________
Marv

Ex ROCK HC & PA Team Head of Support.
Marv is offline   Reply With Quote
Unread 7 Oct 2007, 17:50   #3
Clouds
Registered User
 
Clouds's Avatar
 
Join Date: Jan 2004
Location: United Kingdom
Posts: 1,386
Clouds is a splendid one to beholdClouds is a splendid one to beholdClouds is a splendid one to beholdClouds is a splendid one to beholdClouds is a splendid one to beholdClouds is a splendid one to beholdClouds is a splendid one to behold
Re: mIRC code for Planetarion dumps

Yes, to view details such as planets, galaxies, alliance's etc.
Clouds is offline   Reply With Quote
Unread 7 Oct 2007, 17:52   #4
Marv
Jazz Man
 
Marv's Avatar
 
Join Date: Jan 2003
Posts: 1,494
Marv is a jewel in the roughMarv is a jewel in the roughMarv is a jewel in the rough
Re: mIRC code for Planetarion dumps

I don't have it myself but you could code a simple tool using sockets in mirc code.
__________________
Marv

Ex ROCK HC & PA Team Head of Support.
Marv is offline   Reply With Quote
Unread 7 Oct 2007, 18:44   #5
Phil^
Insomniac
 
Phil^'s Avatar
 
Join Date: May 2003
Posts: 3,583
Phil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus would
Re: mIRC code for Planetarion dumps

Code:
alias dump {
  sockopen pa game.planetarion.com 80
  write -c planet_listing.txt
  echo -s *** Connecting Socket *** 
}    

on *:sockopen:pa:{
  sockwrite -n $sockname GET botfiles/planet_listing.txt HTTP/1.0
  sockwrite -n $sockname Accept: */*
  sockwrite -n $sockname Host: game.planetarion.com
  sockwrite -n $sockname
  //echo -s *** Opened Socket ***
}    


on *:sockread:pa:{
  if ( $sockerr > 0 ) { echo -s *** Error *** | halt }
  echo -s *** Recieving Data ***
  ; read bytes
  sockread 4096 &d
  ; while there are bytes to be read
  while ($sockbr) {
    ; write the data to the end of the file
    bwrite planet_listing.txt -1 -1 &d
    ; read the next bit
    sockread 4096 &d
  }
}

on *:sockclose:pa:{
  echo -s *** Downloading Complete ***
}
Theres a quick one that ive adapted from existing code. No idea if it works as ive not tested it so caveat empor , etc.
It only does the download of planet_listing.txt, you will have to code something to make use of that data yourself.
__________________
Phil^
Phil^ is offline   Reply With Quote
Unread 7 Oct 2007, 19:20   #6
Mzyxptlk
mz.
Alien Invasion Champion, Submarine Champion, Tiger Punch Champion, Barts Watersports Adventure Champion
 
Join Date: Aug 2005
Posts: 8,587
Mzyxptlk has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Mzyxptlk has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Mzyxptlk has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Mzyxptlk has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Mzyxptlk has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Mzyxptlk has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Mzyxptlk has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Mzyxptlk has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Mzyxptlk has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Mzyxptlk has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Mzyxptlk has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.
Re: mIRC code for Planetarion dumps

Use Munin.
__________________
The outraged poets threw sticks and rocks over the side of the bridge. They were all missing Mary and he felt a contented smug feeling wash over him. He would have given them a coy little wave if the roof hadn't collapsed just then. Mary then found himself in the middle of an understandably shocked family's kitchen table. So he gave them the coy little wave and realized it probably would have been more effective if he hadn't been lying on their turkey.
Mzyxptlk is offline   Reply With Quote
Unread 2 Dec 2007, 21:43   #7
SpaceMonkey
Warden
Reactor Champion
 
SpaceMonkey's Avatar
 
Join Date: Jul 2005
Location: The Far Side
Posts: 137
SpaceMonkey is a splendid one to beholdSpaceMonkey is a splendid one to beholdSpaceMonkey is a splendid one to beholdSpaceMonkey is a splendid one to beholdSpaceMonkey is a splendid one to beholdSpaceMonkey is a splendid one to beholdSpaceMonkey is a splendid one to behold
Re: mIRC code for Planetarion dumps

Here is some code to parse the dump and handle rankings. Probably not the greatest but it's pretty fast.

Call the parse routines from the sockclose portion of the code above

Code:
;
;  parseplanetlisting
;
;  Abstract: Called when successful SOCKCLOSE
;  it creates a hash table of planet names for later searching
alias -l parseplanetlisting {
  var %i = 1, %line, %planet, %ruler, %joint, %tick
  var %name = planet_listing
  var %dumpname = %name $+ .txt
  var %bakname = %name $+ .bak
  var %time

  %time = $asctime(hh:nn:ss)		
  echo parseplanetlisting called %time

  hfree %name
  hmake %name 3000

  %line = $read(%dumpname, n, 4)
  %tick = $gettok(%line, 2, 32)
  hadd %name PATICK.PATICK %tick

  ; filter dump so it only has planet lines
  filter -cffrx 7-5000 %dumpname %bakname *:*
  remove %dumpname

  %line = $read(%bakname, n, %i)
  while (%line != $null) {
    ; parse line
    %planet = $gettok($gettok(%line, 4, 9), 1, 34)
    %ruler = $gettok($gettok(%line, 5, 9), 1, 34)
    %joint = $removespaces(%ruler of %planet)
    %line = %line $+ $chr(9) $+ %joint
    hadd %name %joint %line
    write %dumpname %line
    inc %i
    %line = $read(%bakname, n, %i)
  }

  ;also sort to files for rankings
  filter -centuff 10 09 %dumpname %name $+ _xp.txt *
  filter -centuff 9 09 %dumpname %name $+ _value.txt *
  filter -centuff 8 09 %dumpname %name $+ _score.txt *
  filter -centuff 7 09 %dumpname %name $+ _size.txt *

  hsave -o %name %name $+ .dat

  %time = $asctime(hh:nn:ss)		
  echo planetlisting sorted %time
}

;
;  parsegalaxylisting
;
;  Abstract: Called when successful SOCKCLOSE
;
alias -l parsegalaxylisting {
  var %i = 1, %line
  var %name = galaxy_listing
  var %dumpname = %name $+ .txt

  ; filter dump so it only has planet lines
  filter -cffrx 7-5000 %dumpname %dumpname *:*

  ;sort to files for rankings
  filter -centuff 7 09 %dumpname %name $+ _xp.txt *
  filter -centuff 6 09 %dumpname %name $+ _value.txt *
  filter -centuff 5 09 %dumpname %name $+ _score.txt *
  filter -centuff 4 09 %dumpname %name $+ _size.txt *
}
Then these sections can be used to lookup by coords (planet or galaxy) or search by name (planet only). The first 2 aliases are called by the user via on text and on open blocks. The replyto argument is either the channel or nick doing the requesting but you can change that easily enough. The 3rd alias is a binary search on the planet listing that's pretty fast.

Code:
;
; static lookup(replyto,
;               coords)
;
; Abstract: Searches the planet and galaxy listings for <coords>
;
alias -l lookup {
  var %i, %data, %x, %y, %z
  var %gfile = galaxy_listing.txt, %replyto = $1

  if ($3 != $null) {
    %x = $2
    %y = $3
    %z = $4
  }
  else {
    %x = $gettok($2, 1, 58)
    %y = $gettok($2, 2, 58)
    %z = $gettok($2, 3, 58)
  }

  if (%x == $null || %y == $null) {
    msg $1 I need coords to look someone up
    return
  }

  if (%z == $null) {
    %i = $lines(%gfile)
    while (%i > 0) {
      %data = $read(%gfile, n, %i)
      if (%x == $gettok(%data, 1, 9) && %y == $gettok(%data, 2, 9)) {
        displaygalaxy %replyto %data
        return
      }
      dec %i
    }
  }
  else {
    %data = $findplanet(%x, %y, %z)

    if (%data) {
      displayplanet %replyto %data
      return
    }
  }
}

;
;  static finder(replyto,
;                start,
;                search)
;
;  Abstract: look for <search> in the planet listing hash table
;            send entries <start> -> <start> + 4 to <replyto>
;
alias -l finder {
  var %replyto = $1, %search, %n, %display = $3-
  var %n2, %tick, %hash = planet_listing
  var %reply, %i, %start = $int($2), %end, %more
  var %urank, %vrank, %rrank

  %tick = $hget(%hash, PATICK.PATICK)

  if (%start == $null || %start == 0) {
    %start = 1
  }
  else {
    tokenize 32 %display
    %display = [ $ $+ 1- [ $+ [ $calc( $0 -1) ] ] ]
  }

  %search = $removespaces(%display)
  %n = $hfind(%hash, $+(*,%search,*), 0, w)
  if (%start > %n) {
    %start = 1
  }

  %end = %start + 4

  if (%end > %n) %end = %n

  if (%n > %end) %more = $true

  if ($3 != $null || %n > %end) {
    msg %replyto I found %n %display in tick %tick showing %start - %end
  }
  else {
    msg %replyto I found %n %display in tick %tick
  }

  %i = %start
  while (%i <= %end) {
    %n2 = $hfind(%hash, $+(*,%search,*), %i, w)
    if (%i >= %start) {
      displayplanet %replyto $hget(%hash, %n2)
    }
    inc %i
    dec %n
  }
  if (%more == $true) {
    msg %replyto - more matches, use $me find %search $calc(%end + 1)
  }
}

; 
; static findplanet(x,
;                   y,
;                   z)
;
; Abstract: Binary search the planet listing for <x>:<y>:<z>
;
alias -l findplanet {
  var %x = $1, %y = $2, %z = $3
  var %pmin, %pmid, %pmax, %px, %py, %pz, %data

  if ( %x == $null || %y == $null || %z == $null ) {
    return $null
  }

  ; binary search planets
  %pmin = 1
  %pmax = $calc($lines(planet_listing.txt) + 1)
  %pmid = $int($calc((%pmin + %pmax) / 2))
  %data = $read(planet_listing.txt, n, %pmid)
  %px = $gettok(%data, 1, 09)

  while (%pmid > %pmin) {

    if (%px > %x) {
      %pmax = %pmid
    }
    else if (%px < %x) {
      %pmin = %pmid
    }
    else if (%px == %x) {
      %py = $gettok(%data, 2, 09)

      if (%py > %y) {
        %pmax = %pmid
      }
      else if (%py < %y) {
        %pmin = %pmid
      }
      else if (%py == %y) {
        %pz = $gettok(%data, 3, 09)
        if (%pz > %z) {
          %pmax = %pmid
        }
        else if (%pz < %z) {
          %pmin = %pmid
        }
        else if (%pz == %z) {
          break
        }
      }
    }

    %pmid = $int($calc((%pmin + %pmax) / 2))
    %data = $read(planet_listing.txt, n, %pmid)
    %px = $gettok(%data, 1, 09)

    if ( %pmid == %pmin ) {
      %py = $gettok(%data, 2, 09)
      %pz = $gettok(%data, 3, 09)
      break
    }
  }

  if (%x == %px && %y == %py && %z == %pz) {
    return %data
  }
}
They use some helping functionality to remove spaces and display the results

Code:
;
;  removespaces
;
;  Abstract: Remove spaces (character 32) from the arguments and return them concatenated
;
alias -l removespaces {
  var %i, %vrb, %line
  tokenize 32 $1-
  %i = $0
  while (%i > 0) {
    %vrb = $+($,%i)
    %line = $+([ [ %vrb ] ], %line)
    dec %i
  }
  return %line
}

;
; static displayplanet(replyto,
;                      planet)
;
; Abstract: Tells <replyto> about <planet>
;           where <planet> is a line from the planet_listing
;
alias -l displayplanet {
  var %replyto = $1, %reply, %urank, %vrank, %rrank

  tokenize 9 $2-
  %srank = $read(planet_listing_score.txt, nw, $+(*,$11,*))
  %srank = $readn
  %vrank = $read(planet_listing_value.txt, nw, $+(*,$11,*))
  %vrank = $readn
  %rrank = $read(planet_listing_size.txt, nw, $+(*,$11,*))
  %rrank = $readn
  %xrank = $read(planet_listing_xp.txt, nw, $+(*,$11,*))
  %xrank = $readn

  %reply = $+($1,:,$2,:,$3) $&
    $gettok($5, 1, 34) of $gettok($4, 1, 34) $+([,$6,]) $& 
    Score: $bytes($8, b) / %srank $&
    Value: $bytes($9, b) / %vrank $& 
    Roids: $bytes($7, b) / %rrank $&
    XP: $bytes($10, b) / %xrank $&
    Ratio: $base($calc(10000 * $7 / $9), 10, 10, 0, 2) $&
    v/s: $base($calc(%vrank / %rrank), 10, 10, 0, 2)

  msg %replyto %reply
}

;
; static displaygalaxy(replyto,
;                      galaxy)
;
; Abstract: Tells <replyto> about <galaxy>
;           where <galaxy> is a line from the galaxy_listing
;
alias -l displaygalaxy {
  var %replyto = $1, %reply

  tokenize 9 $2-
  %srank = $read(galaxy_listing_score.txt, nw, $+(*,$3,*))
  %srank = $readn
  %vrank = $read(galaxy_listing_value.txt, nw, $+(*,$3,*))
  %vrank = $readn
  %rrank = $read(galaxy_listing_size.txt, nw, $+(*,$3,*))
  %rrank = $readn
  %xrank = $read(galaxy_listing_xp.txt, nw, $+(*,$3,*))
  %xrank = $readn

  %reply = $+($1,:,$2) $&
    $gettok($3, 1, 34) $& 
    Score: $bytes($5, b) / %srank $& 
    Value: $bytes($6, b) / %vrank $&
    Roids: $bytes($4, b) / %rrank $&
    XP: $bytes($7, b) / %xrank $&
    Ratio: $base($calc(10000 * $4 / $6), 10, 10, 0, 2) $&
    v/s: $base($calc(%vrank / %rrank), 10, 10, 0, 2)

  msg %replyto %reply
}
It's a bit messy because it was cobbled together over time as I learnt mirc scripting. Hopefully it's pretty easy to follow although a bit hacky in places. Any suggestions for improvement are welcome as this code is in use (slightly modified).
SpaceMonkey is offline   Reply With Quote
Unread 3 Dec 2007, 22:57   #8
Remy
Ex-Head Multihunter
 
Remy's Avatar
 
Join Date: Sep 2003
Location: At home
Posts: 900
Remy has much to be proud ofRemy has much to be proud ofRemy has much to be proud ofRemy has much to be proud ofRemy has much to be proud ofRemy has much to be proud ofRemy has much to be proud ofRemy has much to be proud of
Re: mIRC code for Planetarion dumps

reading this, i remember why i hate mIRC scripting.

But nice :-)
__________________
R02.0-R4.0: [noob]
R05.0: [Wrath]/[Fury]
R06.0: Quit after 1 week
R7-9: Had an account, but didnt play seriously
R09.5: []LCH[] Officer
R10.0: []LCH[] HC (Rank #9, #1 Gal)
R10.5-R18.0: []LCH[] HC Scanner!
R18.0-R33 : Multihunter, Head MH
R34-.. : [CT] HC
Remy is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Forum Jump


All times are GMT +1. The time now is 16:54.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018