[wpdev-commits] xmlscripts/scripts/commands export.py,1.3,1.4 import.py,1.6,1.7
Brought to you by:
rip,
thiagocorrea
From: Richard M. <dr...@us...> - 2004-06-20 18:51:51
|
Update of /cvsroot/wpdev/xmlscripts/scripts/commands In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27799/commands Modified Files: export.py import.py Log Message: Export Updates Added newline tweaks, should do newlines by system type... Well, posix should do \n and rest \r\n. I think BSD falls under posix. So all should be good. Index: export.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/commands/export.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** export.py 3 Jun 2004 00:28:21 -0000 1.3 --- export.py 20 Jun 2004 18:51:42 -0000 1.4 *************** *** 43,46 **** --- 43,50 ---- import wolfpack from wolfpack.gumps import cGump + import os + + # BaseID's not to save. + nonsaves = ['gem','ore_gem','wood_gem'] def exportcmd( socket, command, arguments ): *************** *** 126,174 **** warnings = '' item = iterator.first i = 0 while item: ! # Build our string ! if format == 1: # Sphere 51a ! output.write( "[WORLDITEM 0%x]\r\n" % item.id ) ! output.write( "SERIAL=0%x\r\n" % item.serial ) ! if item.name != '#': ! output.write( "NAME=%s\r\n" % item.name ) ! output.write( "ID=0%x\r\n" % item.id ) ! output.write( "COLOR=0%x\r\n" % item.color ) ! output.write( "P=%d,%d,%i\r\n\r\n" % ( item.pos.x, item.pos.y, item.pos.z ) ) ! elif format == 2: # WSC ! output.write( "SECTION WORLDITEM %d\r\n{\r\n" % i ) ! output.write( "SERIAL %d\r\n" % item.serial ) ! if item.baseid != '': ! output.write( "BASEID %s\r\n" % item.baseid ) ! if item.name != '#': ! output.write( "NAME %s\r\n" % item.name ) ! output.write( "ID %d\r\n" % item.id ) ! output.write( "X %d\r\n" % item.pos.x ) ! output.write( "Y %d\r\n" % item.pos.y ) ! output.write( "Z %i\r\n" % item.pos.z ) ! output.write( "MAP %i\r\n" % item.pos.map ) ! output.write( "CONT -1\r\n" ) ! output.write( "TYPE 255\r\n" ) # Useful for World Freezes ! output.write( "AMOUNT %d\r\n" % item.amount ) ! output.write( "COLOR %d\r\n" % item.color ) ! output.write( "}\r\n\r\n" ) ! else: # Text ! output.write( "%s 0x%x %i %i %i %i 0x%x\r\n" % ( item.baseid, item.id, item.pos.x, item.pos.y, item.pos.z, item.pos.map, item.color ) ) ! pass if item.amount > 1: ! warnings += 'Item %s has an amount of %d. This information will be lost when made static.<br><br>' % ( hex( item.serial ), item.amount ) eventlist = item.eventlist if len( eventlist ) > 0: ! warnings += 'Item %s has events (%s) assigned to it. It wont be usable when made static.<br><br>' % ( hex( item.serial ), eventlist ) if item.type != 0: ! warnings += 'Item %s is of type %d. It wont be usable when made static.<br><br>' % ( hex( item.serial ), item.type ) i += 1 --- 130,188 ---- warnings = '' + if os.name == 'posix': + newline = "\n" + else: + newline = "\r\n" + item = iterator.first i = 0 while item: ! if not item.baseid in nonsaves: ! # Build our string ! if format == 1: # Sphere 51a ! output.write( "[WORLDITEM 0%x]%s" % ( item.id, newline ) ) ! output.write( "SERIAL=0%x%s" % ( item.serial, newline ) ) ! if item.name != '#': ! output.write( "NAME=%s%s" % ( item.name, newline ) ) ! output.write( "ID=0%x%s" % ( item.id, newline ) ) ! output.write( "COLOR=0%x%s" % ( item.color, newline ) ) ! output.write( "P=%i,%i,%i%s%s" % ( item.pos.x, item.pos.y, item.pos.z, newline ) ) ! elif format == 2: # WSC, Lonewolf Style, Compatible with Linux Worldforge ! output.write( "SECTION WORLDITEM%s" % newline ) ! output.write( "{%s" % newline ) ! output.write( "SERIAL %i%s" % ( item.serial, newline ) ) ! output.write( "ID %i%s" % ( item.id, newline ) ) ! if item.baseid != '': ! output.write( "BASEID %s%s" % ( item.baseid, newline ) ) ! if item.name != '#' or item.name != '': ! output.write( "NAME %s%s" % ( item.name, newline ) ) ! output.write( "X %i%s" % ( item.pos.x, newline ) ) ! output.write( "Y %i%s" % ( item.pos.y, newline ) ) ! output.write( "Z %i%s" % ( item.pos.z, newline ) ) ! output.write( "MAP %i%s" % ( item.pos.map, newline ) ) ! if item.type: ! output.write( "TYPE %i%s" % ( item.type, newline ) ) # World Freeze Requirement ! else: ! output.write( "TYPE 255%s" % newline ) # World Freeze Requirement ! output.write( "COLOR %i%s" % ( item.color, newline ) ) ! output.write( "CONT -1%s" % newline ) ! output.write( "}%s%s" ( newline, newline ) ) ! else: # Text ! output.write( "%s 0x%x %i %i %i %i 0x%x%s" % ( item.baseid, item.id, item.pos.x, item.pos.y, item.pos.z, item.pos.map, item.color, newline ) ) ! # Older Format, no baseid/map saved ! #output.write( "0x%x %i %i %i 0x%x%s" % ( item.id, item.pos.x, item.pos.y, item.pos.z, item.color, newline ) ) if item.amount > 1: ! warnings += 'Item %i has an amount of %i. This information will be lost when made static.<br><br>' % ( hex( item.serial ), item.amount ) eventlist = item.eventlist if len( eventlist ) > 0: ! warnings += 'Item %i has events (%s) assigned to it. It wont be usable when made static.<br><br>' % ( hex( item.serial ), eventlist ) if item.type != 0: ! warnings += 'Item %i is of type %i. It wont be usable when made static.<br><br>' % ( hex( item.serial ), item.type ) i += 1 Index: import.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/commands/import.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** import.py 3 Jun 2004 00:28:21 -0000 1.6 --- import.py 20 Jun 2004 18:51:42 -0000 1.7 *************** *** 48,51 **** --- 48,52 ---- from wolfpack import console from string import lstrip + import os def import_command( socket, command, arguments ): *************** *** 212,216 **** item.id = itemid item.color = color ! item.moveto(x, y, z, map, 1) item.update() count += 1 --- 213,217 ---- item.id = itemid item.color = color ! item.moveto( x, y, z, map ) item.update() count += 1 *************** *** 325,331 **** newitem = wolfpack.additem( "%s" % baseid ) # Generate a new serial for us - #if not newitem: - # newitem = wolfpack.newitem( 1 ) # Generate a new serial for us - newitem.decay = 0 newitem.color = color --- 326,329 ---- |