hs_cp_res.bat
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::@author pdh
::@function 专门用于将生成的动画、通讯协议、路径资源拷贝到程序对应的路径下
::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo off
set OLD_PATH=%cd%
set SRC_TOOL_PATH=..\..\doc\tools
echo "path = "%OLD_PATH%
set PRJ_PATH=..\..\clt\Fishing1.0
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::: 拷贝策划的游戏数值资源
set DST_STATIC_DATA_PATH=%PRJ_PATH%\src\Game\module\Game\fish\static_data
echo "拷贝策划的游戏数值资源。拷贝到 "%DST_STATIC_DATA_PATH%
set SRC_DATA_PATH=%OLD_PATH%\..\..\doc\数据表
cd /d %SRC_DATA_PATH%
set READ_EXCEL_BAT=ReadExcel.bat
if exist %READ_EXCEL_BAT% (
call %READ_EXCEL_BAT%
) else (
echo "Not found READ_EXCEL_BAT="%READ_EXCEL_BAT%
pause
)
cd /d %OLD_PATH%
set DST_SD_PATH=%PRJ_PATH%\src\Game\module\Game\fish\static_data\
xcopy %SRC_DATA_PATH%\static_data_ts %DST_SD_PATH% /E /D /Y
:::破解的奥迪路径太大,无法打包TS程序。放到asset/way中
del /S /Q %DST_SD_PATH%\SD_fishformation.ts
echo "拷贝策划数值资源成功 "%DST_STATIC_DATA_PATH%
::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::: 拷贝动画资源
echo.
echo.
echo.
set DST_ANIM_PATH=%OLD_PATH%\resource\assets\games\fish_res\animation
set SRC_ANIM_PATH=%SRC_TOOL_PATH%\tool_animation
echo "拷贝动画资源到 "%DST_ANIM_PATH%
if not exist %SRC_ANIM_PATH% (
echo "SRC_ANIM_PATH is not exist. "%SRC_ANIM_PATH%
pause
exit 1
)
rmdir /S /Q %DST_ANIM_PATH%
md %DST_ANIM_PATH%
xcopy %SRC_ANIM_PATH% %DST_ANIM_PATH% /E /D /Y
del /S /Q %DST_ANIM_PATH%\*.txt
del /S /Q %DST_ANIM_PATH%\*.tmc
echo "拷贝动画资源成功 "%DST_ANIM_PATH%
cd /d %OLD_PATH%
::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::拷贝鱼路径资源
echo.
echo.
echo.
set DST_WAY_PATH=%OLD_PATH%\resource\assets\games\fish_res\way
set SRC_WAY_PATH=%SRC_TOOL_PATH%\tool_fishpath\Paths
echo "拷贝鱼路径资源到 "%DST_WAY_PATH%
if not exist %SRC_WAY_PATH% (
echo "SRC_WAY_PATH is not exist. "%SRC_WAY_PATH%
pause
exit 1
)
rmdir /S /Q %DST_WAY_PATH%
md %DST_WAY_PATH%
xcopy %SRC_WAY_PATH% %DST_WAY_PATH% /E /D /Y
REM del /S /Q %DST_WAY_PATH%\path*.xml
echo "拷贝鱼路径资源成功 "%DST_WAY_PATH%
cd /d %OLD_PATH%
::::奥迪路径文件太大,写成ts文件无法打包。放到asset/way中作为资源加载
set SRC_FISH_FORMATION=%SRC_DATA_PATH%\static_data_ts\SD_fishformation.ts
set DST_FISH_FORMATION=%DST_WAY_PATH%\SD_fishformation.txt
echo %SRC_FISH_FORMATION%
echo %DST_FISH_FORMATION%
copy %SRC_FISH_FORMATION% %DST_FISH_FORMATION% /Y
::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::将protobuf协议转换后放到客户端代码中
set PROTO_PATH=..\..\protocol
cd /d %PROTO_PATH%
set PROTO_EXE=c2s协议客户端转换.bat
if not exist %PROTO_EXE% (
echo "PROTO_EXE is not exist. "%PROTO_EXE%
pause
exit 1
)
call %PROTO_EXE%
cd %OLD_PATH%
@echo 拷贝msgid文件
xcopy ..\..\protocol\c2s\tsout\*.ts %OLD_PATH%\src\Game\module\Game\fish\net\protobuf\ /Y
@echo 拷贝proto文件
xcopy ..\..\protocol\c2s\*.proto %OLD_PATH%\protobuf\protofile\ /Y
@echo 执行pb-egret generate
cd %OLD_PATH%\protobuf\
call %OLD_PATH%\hs_pb.bat
:::跳转回原始路径下
echo "back--"%cd%
cd /d %OLD_PATH%
pause
hs_pb.bat
@echo ---执行pb-egret generate
set CUR_PATH=%cd%
echo "PB PATH = "%CUR_PATH%
pb-egret generate
cd %CUR_PATH%
生成消息ID.bat
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
:begin
REM
python make_msg_id.py
%pause%
生成PB文件.bat
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
:begin
REM
cd .\c2s
REM for %%i in (*.proto) do (
REM ..\protoc.exe --cpp_out=.\cppout\ %%i
REM )
for %%i in (*.proto) do (
..\protoc.exe --python_out=.\pythonout\ %%i
)
REM for %%i in (*.proto) do (
REM ..\protoc.exe --js_out=.\jsout\ %%i
REM )
REM for %%i in (*.proto) do (
REM ..\protoc.exe --ts_out=.\tsout\ %%i
REM )
cd ..\
REM cd .\s2s
REM for %%i in (*.proto) do (
REM ..\protoc.exe --cpp_out=.\cppout\ %%i
REM )
REM for %%i in (*.proto) do (
REM ..\protoc.exe --python_out=.\pythonout\ %%i
REM )
%pause%
c2s协议服务端转换.bat
cd %cd%
@echo %cd%
start 生成消息ID.bat
@ping -n 2 127.1 >nul
start 生成PB文件.bat
@ping -n 2 127.1 >nul
start copy_proto.bat
@ping -n 2 127.1 >nul
echo "finish transfer"
pause
c2s协议客户端转换.bat
@echo off
cd %cd%
@echo %cd%
@echo 生成msgid
python make_msg_id_client.py
@echo 操作完成
cd %cd%
c2s协议go端转换.bat
@echo off
cd %cd%
@echo %cd%
@echo 生成msgid
python make_msg_id_go.py
@echo 生成pb文件
cd .\c2s
for %%i in (*.proto) do (
..\protoc.exe --go_out=.\goout\ %%i
)
@echo 拷贝msgid文件
xcopy .\goout\C2SMsgId.go ..\..\svr\fishingrobot\src\fishingproto\
@echo 拷贝pb的go文件
cd ..\
python copy_pb_go.py
@echo 完成
pause
copy_pb_go.py
import os
import sys
import shutil
# proto_file_folder_list = [r'\\c2s', r'\\s2s'] 此版本中只有c2s
proto_file_folder_list = [r'\c2s']
out_file_folder_go = r'\goout'
old_postfix = 'proto'
new_postfix_go = 'go'
cur_path = os.getcwd()
proto_file_path = ""
out_file_path_go = ""
def copy_go_file(dest_file_name_with_postfix):
print(dest_file_name_with_postfix)
source_file = out_file_path_go + "\\" + dest_file_name_with_postfix.split('.')[0] + ".pb." + "go"
target_dir = "..\\svr\\fishingrobot\\src\\fishingproto\\" + dest_file_name_with_postfix.split('.')[0].lower() + "pb"
target_file = target_dir + "\\" + dest_file_name_with_postfix.split('.')[0] + ".pb." + "go"
print(source_file)
print(target_dir)
print(target_file)
dirExist = os.path.exists(target_dir)
if not dirExist:
os.makedirs(target_dir)
shutil.copyfile(source_file, target_file)
for i in range(0, len(proto_file_folder_list)):
proto_file_folder = proto_file_folder_list[i]
proto_file_path = cur_path + proto_file_folder
out_file_path_go = proto_file_path + out_file_folder_go
print(out_file_path_go)
file_list = os.listdir(proto_file_path)
for file_obj in file_list:
file_path = os.path.join(proto_file_path, file_obj)
cur_file_postfix = str(file_obj.split('.')[-1])
if cur_file_postfix == old_postfix:
source_file_name_with_postfix = str(file_path.split('\\')[-1])
new_file_name_with_postfix = str(source_file_name_with_postfix.split('.')[0]) + '.' + new_postfix_go
copy_go_file(new_file_name_with_postfix)
copy_proto_client.bat
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
:begin
REM
REM xcopy .\c2s\cppout\*.pb.cc ..\..\cppserver\server1.0\src\protocol\c2s\ /Y
REM xcopy .\c2s\cppout\*.h ..\..\cppserver\server1.0\src\protocol\c2s\ /Y
xcopy .\c2s\pythonout\*.py ..\svr\fishingserver1.0\protocol\c2s\ /Y
REM xcopy .\s2s\cppout\*.pb.cc ..\..\cppserver\server1.0\src\protocol\s2s\ /Y
REM xcopy .\s2s\cppout\*.h ..\..\cppserver\server1.0\src\protocol\s2s\ /Y
REM xcopy .\s2s\pythonout\*.py ..\..\pythonserver\catchfish1.0\protocol\s2s\ /Y
%pause%
copy_proto.bat
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
:begin
REM
REM xcopy .\c2s\cppout\*.pb.cc ..\..\cppserver\server1.0\src\protocol\c2s\ /Y
REM xcopy .\c2s\cppout\*.h ..\..\cppserver\server1.0\src\protocol\c2s\ /Y
xcopy .\c2s\pythonout\*.py ..\svr\fishingserver1.2\protocol\c2s\ /Y
REM xcopy .\s2s\cppout\*.pb.cc ..\..\cppserver\server1.0\src\protocol\s2s\ /Y
REM xcopy .\s2s\cppout\*.h ..\..\cppserver\server1.0\src\protocol\s2s\ /Y
REM xcopy .\s2s\pythonout\*.py ..\..\pythonserver\catchfish1.0\protocol\s2s\ /Y
%pause%
make_msg_id_client.py
# -*- coding: utf-8 -*-
import os
import sys
# proto_file_folder_list = [r'\\c2s', r'\\s2s'] 此版本中只有c2s
proto_file_folder_list = [r'c2s']
out_file_folder_ts = r'tsout'
old_postfix = 'txt'
new_postfix_ts = 'ts'
cur_path = os.getcwd()
proto_file_path = ""
out_file_path_ts = ""
def create_ts_file(source_file_name_with_postfix, dest_file_name_with_postfix):
print(source_file_name_with_postfix)
print(dest_file_name_with_postfix)
if not os.path.isdir(out_file_path_ts):
os.makedirs(out_file_path_ts)
pt = os.path.sep.join((out_file_path_ts, dest_file_name_with_postfix))
f = open(pt, 'w', encoding='UTF-8')
file_name = source_file_name_with_postfix.split('.')[0]
f.writelines(u'//程序自动生成,消息id文件\n')
f.writelines('class ' + file_name + '{' + '\n')
# 先写协议名称,再写根据id得到名称
pt = os.path.sep.join((proto_file_path, source_file_name_with_postfix))
with open(pt, "r", encoding='UTF-8') as read:
while True:
line = read.readline()
if not line:
break
str_line = line.strip()
if not len(str_line):
continue
sp = str_line.split()
if len(sp) != 3:
print("error line={} , sp[{}]".format(line, sp))
sys.exit(0)
continue
name = sp[0]
id_key = sp[1]
note = sp[2]
new_line = ' public static ' + name.upper() + ':string = "' + \
name + '"; // ' + note
f.writelines(new_line)
f.writelines('\n')
f.writelines('\n')
f.writelines(' public static getClassNameById(msgId:number):string {\n')
f.writelines(' switch(msgId) {\n')
pt = os.path.sep.join((proto_file_path, source_file_name_with_postfix))
with open(pt, "r", encoding='UTF-8') as read:
whil