Exemple #1
0
    def __searchMark(self, filename):
        line_num = 0
        charset = self.__detectCharset(filename)
        regex = r'\s*?' + self.__options__['mark_format'] + r'\s*?'

        if '../../src/'.replace('/', os.path.sep) in filename and charset.upper() != 'UTF-8-SIG':
            Message.ShowWarning('期望文件 %s 的编码为 UTF-8-SIG 而实际上是 %s' % (filename, charset.upper()))
            return

        try:
            textfile = open(filename, encoding=charset)
            for line in textfile:
                line_num = line_num + 1
                if '//' not in line:
                    continue

                re_match = re.match(regex, line)
                if not re_match:
                    continue

                if str(re_match.group(1)) in self.mark_dict:
                    Message.ShowError('发现重复的代码注入标记: ' + re_match.group(0))
                    Common.exit_with_pause(-1)

                self.mark_dict[re_match.group(1)] = {
                    'index' : int(re_match.group(1)),
                    'filepath' : filename,
                    'line' : line_num
                }
            textfile.close()
        except Exception as err:
            Message.ShowError('文件 : %s | 错误信息 : %s' % (filename, err))
Exemple #2
0
def compile_renewal(version):
    '''
    编译复兴后版本
    '''
    time.sleep(3)
    print('')
    
    define_options = {}

    if os.getenv("DEFINE_CRASHRPT_APPID"):
        define_options["CRASHRPT_APPID"] = '\\"%s\\"' % os.getenv("DEFINE_CRASHRPT_APPID")
    if os.getenv("DEFINE_CRASHRPT_PUBLICKEY"):
        define_options["CRASHRPT_PUBLICKEY"] = '\\"%s\\"' % os.getenv("DEFINE_CRASHRPT_PUBLICKEY")

    define_options["GIT_BRANCH"] = '\\"%s\\"' % Common.get_pandas_branch(project_slndir)
    define_options["GIT_HASH"] = '\\"%s\\"' % Common.get_pandas_hash(project_slndir)

    define_values = define_builder(define_options)
    
    if not compile_sub(define_values, '复兴后', version):
        Message.ShowError('编译复兴前版本时发生了一些错误, 请检查...')
        Common.exit_with_pause(-1)
    
    # 将之前 compile_prere 中临时重命名的复兴前产物全部改回正常的文件名
    shutil.move(slndir('login-server-pre-t.exe'), slndir('login-server-pre.exe'))
    shutil.move(slndir('login-server-pre-t.pdb'), slndir('login-server-pre.pdb'))
    shutil.move(slndir('char-server-pre-t.exe'), slndir('char-server-pre.exe'))
    shutil.move(slndir('char-server-pre-t.pdb'), slndir('char-server-pre.pdb'))
    shutil.move(slndir('map-server-pre-t.exe'), slndir('map-server-pre.exe'))
    shutil.move(slndir('map-server-pre-t.pdb'), slndir('map-server-pre.pdb'))
    
    print('')
Exemple #3
0
def compile_renewal(version):
    '''
    编译复兴后版本
    '''
    time.sleep(3)
    print('')

    define_options = {}

    if os.getenv("DEFINE_CRASHRPT_APPID"):
        define_options["CRASHRPT_APPID"] = '_CT(\\"%s\\")' % os.getenv(
            "DEFINE_CRASHRPT_APPID")
    if os.getenv("DEFINE_CRASHRPT_PUBLICKEY"):
        define_options["CRASHRPT_PUBLICKEY"] = '_CT(\\"%s\\")' % os.getenv(
            "DEFINE_CRASHRPT_PUBLICKEY")

    define_options["GIT_BRANCH"] = '\\"%s\\"' % Common.get_pandas_branch(
        project_slndir)
    define_options["GIT_HASH"] = '\\"%s\\"' % Common.get_pandas_hash(
        project_slndir)

    define_values = define_builder(define_options)

    if not compile_sub(define_values, '复兴后', version):
        Message.ShowError('编译复兴前版本时发生了一些错误, 请检查...')
        Common.exit_with_pause(-1)

    print('')
Exemple #4
0
def compile_prere(version):
    '''
    编译复兴前版本
    '''
    time.sleep(3)
    print('')
    
    define_options = {
        "PRERE": ""
    }
    
    if os.getenv("DEFINE_CRASHRPT_APPID"):
        define_options["CRASHRPT_APPID"] = '\\"%s\\"' % os.getenv("DEFINE_CRASHRPT_APPID")
    if os.getenv("DEFINE_CRASHRPT_PUBLICKEY"):
        define_options["CRASHRPT_PUBLICKEY"] = '\\"%s\\"' % os.getenv("DEFINE_CRASHRPT_PUBLICKEY")
        
    define_options["GIT_BRANCH"] = '\\"%s\\"' % Common.get_pandas_branch(project_slndir)
    define_options["GIT_HASH"] = '\\"%s\\"' % Common.get_pandas_hash(project_slndir)

    define_values = define_builder(define_options)
    
    if not compile_sub(define_values, '复兴前', version):
        Message.ShowError('编译复兴前版本时发生了一些错误, 请检查...')
        Common.exit_with_pause(-1)

    # 将复兴前版本的编译产物重命名一下, 避免编译复兴后版本时被覆盖
	# 因 ab7a827 的修改每次清理工程时, 也会同时清理复兴前的编译产物, 所以这里需要临时重命名
    shutil.move(slndir('login-server.exe'), slndir('login-server-pre-t.exe'))
    shutil.move(slndir('login-server.pdb'), slndir('login-server-pre-t.pdb'))
    shutil.move(slndir('char-server.exe'), slndir('char-server-pre-t.exe'))
    shutil.move(slndir('char-server.pdb'), slndir('char-server-pre-t.pdb'))
    shutil.move(slndir('map-server.exe'), slndir('map-server-pre-t.exe'))
    shutil.move(slndir('map-server.pdb'), slndir('map-server-pre-t.pdb'))
    
    print('')
Exemple #5
0
 def processFile(self, filename, rules, version):
     displaypath = filename if self.__lastdir__ == '' else os.path.relpath(filename, os.path.join(self.__lastdir__, '../'))
     Message.ShowStatus('正在更新 %s 中的版本号到: %s' % (displaypath, version))
     for rule in rules:
         usever = self.versionFormat(version, rule['vmode'])
         replto = rule['replto'] % usever
         Common.match_file_resub(filename, rule['regex'], replto)
Exemple #6
0
def main():
    os.chdir(os.path.split(os.path.realpath(__file__))[0])

    welecome()
    print('')

    confirm = InputController().requireBool({
        'tips': '是否立刻进行文件编码转换?',
        'default': False
    })

    if not confirm:
        Message.ShowInfo('您取消了操作, 程序终止...\n')
        Common.exitWithPause()

    count = CharsetConverter({
        'ignore_files': ['Makefile', 'Makefile.in', 'CMakeLists.txt'],
        'process_exts': ['.hpp', '.cpp']
    }).convertDirectory('../../src', 'UTF-8-SIG')

    if count <= 0:
        Message.ShowInfo('很好! 源代码文件都已转换为 UTF-8-SIG 编码.')

    print('')

    Common.exitWithPause()
Exemple #7
0
    def __init__(self, options):
        self.__options__ = options
        self.mark_dict = {}

        if not self.detect(self.__options__['source_dirs']):
            Message.ShowError('无法成功定位所有需要的代码注入点, 程序终止!')
            Common.exit_with_pause(-1)
        else:
            Message.ShowStatus('已成功定位所有代码注入点.\n')
Exemple #8
0
def main():
    os.chdir(os.path.split(os.path.realpath(__file__))[0])

    Common.welcome('地图标记添加助手')

    options = {
        'source_dirs' : '../../src',
        'process_exts' : ['.hpp', '.cpp'],
        'mark_format' : r'// PYHELP - MAPFLAG - INSERT POINT - <Section (\d{1,2})>',
        'mark_enum': InjectPoint,
        'mark_configure' : [
            {
                'id' : InjectPoint.PANDAS_SWITCH_DEFINE,
                'desc' : 'pandas.hpp @ 宏定义'
            },
            {
                'id' : InjectPoint.MAP_MAPFLAG_DEFINE,
                'desc' : 'map.hpp @ MF_XXX 常量定义'
            },
            {
                'id' : InjectPoint.SCRIPT_CONSTANTS_EXPORT,
                'desc' : 'script_constants.hpp @ MF_XXX 常量导出'
            },
            {
                'id' : InjectPoint.ATCOMMAND_MAPFLAG_BLOCK,
                'desc' : 'atcommand.cpp @ mapflag GM指令的赋值屏蔽处理'
            },
            {
                'id' : InjectPoint.MAP_GETMAPFLAG_SUB,
                'desc' : 'map.cpp @ map_getmapflag_sub 的读取标记处理'
            },
            {
                'id' : InjectPoint.MAP_SETMAPFLAG_SUB,
                'desc' : 'map.cpp @ map_setmapflag_sub 的设置标记处理'
            },
            {
                'id' : InjectPoint.NPC_PARSE_MAPFLAG,
                'desc' : 'npc.cpp @ npc_parse_mapflag 可选的标记处理'
            },
            {
                'id' : InjectPoint.ATCOMMAND_MAPINFO,
                'desc' : 'atcommand.cpp @ ACMD_FUNC(mapinfo) 可选的地图信息输出'
            },
            {
                'id' : InjectPoint.SCRIPT_SETMAPFLAG,
                'desc' : 'script.cpp @ setmapflag 可选的脚本设置标记参数处理代码'
            },
            {
                'id' : InjectPoint.SCRIPT_GETMAPFLAG,
                'desc' : 'script.cpp @ getmapflag 可选的脚本读取标记参数处理代码'
            }
        ]
    }

    guide(Injecter(options))
    Common.exit_with_pause()
Exemple #9
0
def main():
    os.chdir(os.path.split(os.path.realpath(__file__))[0])

    welecome()

    options = {
        'source_dirs' : '../../src',
        'process_exts' : ['.hpp', '.cpp'],
        'mark_format' : r'// PYHELP - MAPFLAG - INSERT POINT - <Section (\d{1,2})>',
        'mark_counts' : 11
    }

    guide(InjectController(options))
    Common.exitWithPause()
 def requireText(self, options):
     print('-' * 70)
     Message.ShowSelect(options['tips'] + ':')
     result = input(options['prefix'])
     if not result:
         Message.ShowError('请至少输入一个字符. 程序终止')
         print('-' * 70)
         Common.exitWithPause(-1)
     result = options['prefix'] + result
     if options['upper']:
         result = result.upper()
     Message.ShowInfo('您输入的是: ' + result)
     print('-' * 70)
     print('\n')
     return result
Exemple #11
0
def main():
    os.chdir(os.path.split(os.path.realpath(__file__))[0])

    Common.welcome('版本号修改辅助脚本')

    print('')

    # 读取当前的 Pandas 主程序版本号
    pandas_ver = Common.get_pandas_ver(os.path.abspath(project_slndir),
                                       origin=True)
    Message.ShowInfo('当前模拟器的主版本是 %s' % pandas_ver)

    print('')

    # 询问获取升级后的目标版本
    newver = Inputer().requireText(
        {'tips': '请输入新的版本号 (四段式: 1.0.0.1, 最后一段为 1 则表示为开发版)'})

    if not isVersionFormatValid(newver):
        Message.ShowError('你输入的版本号: %s 不符合四段式规则, 请重试...' % newver)
        Common.exit_with_pause(-1)

    # 执行更新操作
    ver = VersionUpdater(options)
    ver.updateDirectory(slndir('src'), newver)

    Common.exit_with_pause()
 def requireInt(self, options):
     print('-' * 70)
     Message.ShowSelect(options['tips'] + ':')
     result = input(options['prefix']) if 'prefix' in options else input()
     if not result:
         if not ('allow_empty' in options and options['allow_empty']):
             Message.ShowError('请至少输入一个数字. 程序终止')
             print('-' * 70)
             Common.exit_with_pause(-1)
         result = '0'
     if not result.isdigit():
         Message.ShowError('请输入一个数字而不是字符串. 程序终止')
         print('-' * 70)
         Common.exit_with_pause(-1)
     Message.ShowInfo('您输入的是: ' + result)
     print('-' * 70)
     print('')
     return int(result)