liuzhaoqi 发表于 2009-3-8 16:29

解开特殊兵种补丁(更新修改后main.pack下载)

这个。。。我以没用过特殊版。。。但是我看到了一个解开特殊兵种的方法
地址:http://www.twcenter.net/forums/showthread.php?t=233986

于是我用repack的方法做了一下...我看了看特殊兵种相关帖。。。找了两个有代表性的截图作证。。。大家试试看吧

请先去http://www.python.org/download/releases/3.0.1/ 下载安装Python 3.0.1

使用方法。。。解压到data文件夹下,将原先的main.pack重命名为main.pack_backup,运行repack.bat

注意:要先显示文件扩展名
控制面板-文件夹选项-查看
找到“隐藏已知文件类型的扩展名”
取消勾选







好像有人弄不出来。。。所以我将main.pack上传到纳米盘了。。。31MB
http://www.namipan.com/d/main.7z/c44535542454d9759aee56a5cb0f0b998b74b569b553f101

帅小生 发表于 2009-3-8 16:36

是军乐队吗?

liuzhaoqi 发表于 2009-3-8 16:37

就是特殊版用激活码激活的那几个兵种

22834035 发表于 2009-3-8 16:51

测试了,无效

liuzhaoqi 发表于 2009-3-8 16:53

回复 4# 22834035 的帖子

您是按照安装步骤来的么
复制到data改名,执行bat

22834035 发表于 2009-3-8 16:54

原帖由 liuzhaoqi 于 2009-3-8 16:53:00 发表
您是按照安装步骤来的么
复制到data改名,执行bat
是的啊
解压到data文件夹下,将原先的main.pack重命名为main.pack_backup,运行repack.bat

22834035 发表于 2009-3-8 16:56

楼主,你成功了吗

liuzhaoqi 发表于 2009-3-8 16:58

在play battle里面
time period 选择 late

选择图二的那个国家。。。看看有没有death那个兵种

或者将backup改回来。。。。看看补丁后和补丁前有没有多出兵种

liuzhaoqi 发表于 2009-3-8 16:58

回复 7# 22834035 的帖子

我成功了。。。截图就是我自己的,补丁也是我做的。。。。

22834035 发表于 2009-3-8 17:00

里面就一个main文件,然后重命名main.pack_backup?

liuzhaoqi 发表于 2009-3-8 17:04

main.pack文件重名为main.pack_backup

运行后会出现一个新的main.pack

新生成的是更改后的
如果想要还原就删除它
然后把main.pack_backup命名回去

22834035 发表于 2009-3-8 17:10

IOError:NO such file or directory:'main.pack_backup'
按任意键继续。。。
执行Repack.bat后的最后一句话,版主看看是哪错了

liuzhaoqi 发表于 2009-3-8 17:12

就是找不到main.pack_backup这个文件。。。。。
将你的data目录截图给我看

22834035 发表于 2009-3-8 17:14

原帖由 liuzhaoqi 于 2009-3-8 17:12:00 发表
就是找不到main.pack_backup这个文件。。。。。
将你的data目录截图给我看
直接重命名,改了没用啊,MAIN.PACK文件,你点重命名后是MAIN,然后加上.pack_backup,运行BAT文件,就是这个结果

liuzhaoqi 发表于 2009-3-8 17:22

原来。。。你的后缀名是隐藏了的
更改完后会提示改变后缀后会不可识别

控制面板-文件夹选项-查看
找到“隐藏已知文件类型的扩展名”
取消勾选

22834035 发表于 2009-3-8 17:26

原帖由 liuzhaoqi 于 2009-3-8 17:22:00 发表
原来。。。你的后缀名是隐藏了的
更改完后会提示改变后缀后会不可识别

控制面板-文件夹选项-查看
找到“隐藏已知文件类型的扩展名”
取消勾选
大意了,不好意思,版主~

030626 发表于 2009-3-8 17:47

測試後可用
簡單來說就是要刪除main.pack裡的units_to_special_editions_juncs_tables

liuzhaoqi 发表于 2009-3-8 17:53

貌似是units_to_special_editions_juncs_tables下的一个文件。。。。删除掉应该会出错的

router1219 发表于 2009-3-8 18:08

不行阿...
IOError: Permission denied: 'main.pack'
按任意鍵繼續...

liuzhaoqi 发表于 2009-3-8 18:14

原帖由 router1219 于 2009-3-8 18:08:00 发表
不行阿...
IOError: Permission denied: 'main.pack'
按任意鍵繼續...

按照步骤做了?

router1219 发表于 2009-3-8 18:17

我都照步驟做了..我試了好幾次= =...
會不會因為我是用vista?

liuzhaoqi 发表于 2009-3-8 18:19

原帖由 router1219 于 2009-3-8 18:17:00 发表
我都照步驟做了..我試了好幾次= =...
會不會因為我是用vista?
能将你的data目录截图下来给我看看么
为什么会出现main.pack呢

lg6808 发表于 2009-3-8 18:21

感谢LZ发出这么有用的补丁,哪天我也想学学

router1219 发表于 2009-3-8 18:26

liuzhaoqi 发表于 2009-3-8 18:27

原帖由 router1219 于 2009-3-8 18:26:00 发表




没上传成功。。。。。给你个地址xs.to

router1219 发表于 2009-3-8 18:29

抱歉。
圖來了

liuzhaoqi 发表于 2009-3-8 18:34

原帖由 router1219 于 2009-3-8 18:29:00 发表
抱歉。
圖來了


全部文件。。。我想看看是不是有和main冲突的。。。。。
没用过vista真郁闷

router1219 发表于 2009-3-8 18:38

http://xs137.xs.to/xs137/09100/1267.jpg

liuzhaoqi 发表于 2009-3-8 18:40

干脆你自己做一个
创建一个文本文档
然后把下面代码复制进去
把后缀改为.py# ===================================================================================
#                            etw_demo.py                                                   |
# ===================================================================================
#                                                                                       |
# Programmer:   Stefan Reutter (alpaca)                                                 |
#                                                                                       |
# Date:22 Feb 2009                                                                                 |
# Version: 1.3                                                                                                                                                |
# ---------------------------------------------------------------------------------      |
#                                                                                       |
# An unpacker script for the ETW demo. It's Python 3 code, incompatible with 2.x      |
# ===================================================================================

import struct, os, sys, re
from xml.dom import minidom

# For easy file reading and writing interactions
def readLong(fhandle):
    return struct.unpack('l', fhandle.read(4))
def readShort(fhandle):
    return struct.unpack('h', fhandle.read(2))
def readByte(fhandle):
    return struct.unpack('B', fhandle.read(1))
def readBool(fhandle):
    val = fhandle.read(1)
    if val == "00":
      return False
    else:
      return True
   
def writeLong(fhandle, value):
    fhandle.write(struct.pack('l',value))
def writeShort(fhandle, value):
    fhandle.write(struct.pack('h',value))
def writeByte(fhandle, value):
    fhandle.write(struct.pack('B',value))
def writeBool(fhandle, value):
    if value:
      fhandle.write('x01')
    else:
      fhandle.write('x00')
      
def copyFast(fhandle1, fhandle2, length):
      # do a faster copy of file contents
      i = 0
      # read MB-sized chunks as long as possible
      j = length//(2**20)
      while i < j:
                fhandle2.write(fhandle1.read(2**20))
                i+=1
      fhandle2.write(fhandle1.read(length%(2**20)))
      return True
               
def removeDir(path):
      # remove all files in a folder
      if not (os.path.isdir(path)):
                return True
      
      files = os.listdir(path)
      
      for x in files:
                fullpath=os.path.join(path, x)
                if os.path.isfile(fullpath):
                        os.remove(fullpath)
                elif os.path.isdir(fullpath):
                        removeDir(fullpath)
      os.rmdir(path)

def parseArgs(args):
      pack = packFile('demo1.pack','unpacked')
      
      # create argument tree
      argtree = []
      for arg in args:
                if arg.startswith('-'):
                        argtree.append(])
                else:
                        argtree[-1].append(arg)
      
      # wander the tree, top level always has hyphenated arguments
      for arg in argtree:
                # case 1: change pack
                if arg == '-p':
                        for file in arg:
                              print()
                              print('Changing pack to '+file)
                              print()
                              pack.newPack(file,pack.outputdir)
                              pack.readPackDefinition()
                # case 2: list
                elif arg == '-l':
                        if len(arg) > 0:
                              for file in arg:
                                        pack.printEyeCandy(str(file))
                        else:
                              pack.printEyeCandy('./list.txt')
                # case 3: unpack
                elif arg == '-u':
                        for file in arg:
                              if file == 'all':
                                        for i in range(len(pack.files)):
                                                pack.exportFile(i)
                              else:
                                        pack.exportFile(file)
                # case 4: unpack (regexp)
                elif arg == '-ur':
                        for file in arg:
                              pack.exportFile(file, True)
                # case 5: change output directory
                elif arg == '-o':
                        for file in arg:
                              print()
                              print('Changing output directory to '+file)
                              print()
                              pack.changeOutputDir(file)
                # case 6: repack
                elif arg == '-r':
                        print('Repacking files from '+arg)
                        pack.repackFiles(arg, arg)
      pack.packClose()
                        

class packFile:
      def __init__(self, path='', outputdir=None):
                self.handle = None
                self.wiped = False
                self.files = []
                self.numFiles = 0
                self.arr = 0
                self.init = b''
                self.outputdir = outputdir
                self.defLength = 0
                self.path = path
      
      def newPack(self,path,outputdir=None):
                # safely open new pack
                if self.handle:
                        self.handle.close()
                        self.handle = None
                self.files = []
                self.numFiles = 0
                self.arr = 0
                self.init = b''
                self.outputdir = outputdir
                self.defLength = 0
                self.path = path
      
      def changeOutputDir(self,path):
                self.outputdir = path
                self.wiped = False
      
      def packOpen(self):
                if not self.handle:
                        self.handle = open(self.path,"rb")
                return self.handle
                        
      def packClose(self):
                self.handle.close()
               
      def readPackDefinition(self):   
                pack = self.packOpen()
               
                # skip empty bytes and stuff at the start
                self.init = pack.read(16)

                # read number of files
                self.numFiles = readLong(pack)
               
                # read ??
                self.defLength = readLong(pack)
               
                # store the offset of a certain file
                offset = 0
                # read file metadata
                for i in range(self.numFiles):
               
                        # read length of file
                        length = readLong(pack)
                        
                        # read file name
                        char = ''
                        filename = ''
                        while char != b'x00':
                              char = pack.read(1)
                              if (char != b'x00'):
                                        filename += char.decode()
                        self.files.append((filename,length,offset))
                        offset += length
                        
      def exportFile(self, arg, regexp = False):
                try:
                        arg = int(arg)
                        # option a: arg is an index
                        list = ]
                except:
                        # option b: arg is a string
                        if regexp:
                              list = filter(lambda x: re.search(str(arg),x),self.files)
                        else:
                              list = filter(lambda x: arg in x,self.files)
                if not self.wiped:
                        if self.outputdir:
                              removeDir(self.outputdir)
                        self.wiped = True
                for (path,length,offset) in list:
                        if length == 0:
                              continue
                        print('Exporting '+path+', length: '+str(length)+', at offset: '+str(offset))
                        
                        # create output directory      
                        dir = os.path.split(os.path.join(self.outputdir,path))
                        if not os.path.isdir(dir):
                              os.makedirs(dir)
                        output = open(os.path.join(self.outputdir,path),'wb')
                        
                        # open pack and go to offset
                        pack = self.packOpen()
                        pack.seek(self.defLength+offset+24) #+24 for the info at the start
                        # copy content
                        copyFast(pack,output,length)
                        output.close()
                return True
               
      def repackFiles(self, repackFile, targetFile):
                # reads file info from a file list to repack it
                newFileList = {}
                xml_doc = minidom.parse(repackFile)
                packsNode = xml_doc.documentElement
                for packNode in packsNode.getElementsByTagName("pack"):
                        packName = str(packNode.getElementsByTagName("name").childNodes.data)
                        filesNode = packNode.getElementsByTagName("files")
                        for fileNode in filesNode.getElementsByTagName("file"):
                              fileName = str(fileNode.getElementsByTagName("name").childNodes.data)
                              filePath = str(fileNode.getElementsByTagName("path").childNodes.data)
                              fileSize = os.path.getsize(filePath)
                              newFileList = (filePath,fileSize)
                              found = False
                              for i in range(len(self.files)):
                                        fileItem = self.files
                                        if fileItem == fileName:
                                                self.files = (fileName, fileSize, fileItem)
                                                found = True
                                                break
                              if not found:
                                        print('Error: file not in pack description: '+fileName)
                                        return False
                                       
               
                pack = self.packOpen()
                with open(targetFile,'wb') as copy:
                        # write stuff at the beginning
                        copy.write(self.init)
                        writeLong(copy,self.numFiles)
                        writeLong(copy,self.defLength)
                        print('Writing index')
                        # write index
                        for (path, length, offset) in self.files:
                              writeLong(copy,length)
                              copy.write(bytes(path.encode('utf-8')))
                              copy.write(b'x00')
                        
                        # write files
                        for (path, length, offset) in self.files:
                              if length ==0:
                                        continue
                              print('Repacking '+path)
                              # if the file is being replaced, read from disk
                              if path in newFileList:
                                        with open(newFileList,'rb') as input:
                                                copyFast(input,copy,length)
                              # if it's the file from the old pack, copy that
                              else:
                                        pack.seek(offset+self.defLength+24) #+24 for the info at the start
                                        copyFast(pack,copy,length)
                return True
                        
                              
      
      def printEyeCandy(self, outfile):
                output = open(outfile,'w')
                for (path,length,offset) in self.files:
                        output.write(str(path)+'rn')
                output.close()
               

# main
parseArgs(sys.argv)和repack文件夹一起放到你游戏的data目录下。。。。把你的main.pack改名为main.pack_backup


然后再创建个文本文档
把下面代码复制进去<?xml version="1.0"?>
<packs>
      <pack>
                <name>main.pack</name>
                <files>
                        <file>
                              <name>dbunits_to_special_editions_juncs_tablesunits_to_special_editions_juncs</name>
                              <path>repackdbunits_to_special_editions_juncs_tablesunits_to_special_editions_juncs</path>
                        </file>
                </files>
      </pack>
</packs>把后缀改为.xml

在创建文本文档
把下面代码复制进去@echo off
cls
echo Repacking...
echo.
emp_repacker.py -pmain.pack_backup -r repack.xml main.pack
pause把后缀改为.bat

运行.bat

koololo 发表于 2009-3-8 18:44

还是不会。。。。。。。
页: [1] 2
查看完整版本: 解开特殊兵种补丁(更新修改后main.pack下载)