Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Rise of Nations > RoN-Creation&Files > Perl function for decoding RoN recordings
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!
31.Aug: `MOR` THIRD SEASON SIGN-UPS UNDERWAY
26.Aug: EMERGES AS THE WINNER
20.Aug: OH SO LOVABLE

bottom of page
  
Author
Thread    < Last Thread     Next Thread > Post New Thread     Post A Reply
Carch is offline Carch
Warlord
San Jose, CA, USA
Dec 1999
time: 21:29
  Old Post 28-07-2003 10:20 Visit Carch's homepage!
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
Perl function for decoding RoN recordings Support Apolyton, buy Alpha Centauri

I just posted this over on MFO, figured I'd share the wealth...

First thing you need to know is that a RoN recording is a gzip file. After you've unzipped it by whatever means (for Perl, I used Compress::Zlib, PHP supports gzip files directly), this function will decode the header for you.

If you need more info on the perl "unpack" function which is pretty much the guts of this, see http://www.perldoc.com/perl5.8.0/pod/func/unpack.html

I think the only unpack flags I use are:
C - unsigned byte
V - little-endian (VAX) long
v - little-endian (VAX) short
x - skip bytes
V/v - little-endian long count followed by little-endian short array (unicode)

code:
# ronrec.pl # Perl function # Given an uncompressed header of a Rise of Nations recording file, # extracts the data into various enumerations. # This version of the function does NO error checking. sub ronrec() { my ($buf) = @_; my ($csig1, $csig2, @uversion) = unpack("CCV/v", $head); my $version = join('', map(chr, @uversion)); my $ofs = 2 + 4 + 2 * ($#uversion + 1); # variable names as in rules.xml my ( $Vvers, $Vseed, $Vlong1, $Vlong2, Vlong3, $Vflag, $cgamesytle, $cmapstyle, $cmapsize, $c04, $c05, $cgamespeed, $cgamerules, $cdifficulty, $cstartingtown, $cstartingresources, $cdefenderresources, $ctechcost, $crevealmap, $cpoplimit, $crushrules, $ccannontime, $cstartingtech, $c18, $cendingtech, $celimination, $cvictory, $cwonderwin, $cscore, $cpopwin, $ctimelimit, $cchair, $ceconwin, $c28, $c29 ) = unpack("x$ofs V6C29", $head); my $defenderage = $cstartingresources; # for Barbarians at the Gate my $ofs += 6*4 + 29; my (@ppov, @pflag, @pnation, @pcolor, @pteam, @pskill, @pnum, @px00, @px02, @pname); for (my $player = 0; $player < 8; $player++) { my ($ctag, $vpov) = unpack("x$ofs cv"); $ofs += 3; if ($vpov) { my ($vpflag, $cnation, $ccolor, $cteam, $cskill, $cnum, $cx00, $cx02, @uname) = unpack("x$ofs x48vc7V/v", $head); ofs += 48 + 2 + 7 + 4 + 2 * ($#uname + 1); # !!! Note that this unpack skips 48 bytes at the start ofe each player info. # !!! I have never seen anything but zeros there, as of this writing, # !!! but one never knows. my $name = join('', map(chr, @uname)); $name = "Player $cnum" if not $name; $ppov[$player] = $vpov; $pflag[$player] = $cpflag; $pnation[$player] = $cnation; $pcolor[$player] = $ccolor; $pteam[$player] = $cteam; $pskill[$player] = $cskill; $pnum[$player] = $cnum; $px00[$player] = $cx00; # only value I have seen here is 0 $px02[$player] = $cx02; # only value I have seen here is 2 $pname[$player] = $name; } } # Now you have all the game info in various variables! # Stuff 'em into globals, make a hash and return 'em, print 'em, whatever. }

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:29.
Apolyton Time is 00:29.
    top of page
Rate This Thread:
Forum Jump:
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0258 seconds (84.40% PHP - 15.60% MySQL) with 30 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net