mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-10-31 08:47:54 +00:00
update tools
This commit is contained in:
parent
4f44d8ae1c
commit
36c45ceae8
7 changed files with 219 additions and 30 deletions
2
tools/.gitignore
vendored
Executable file
2
tools/.gitignore
vendored
Executable file
|
@ -0,0 +1,2 @@
|
|||
build
|
||||
build/*
|
34
tools/build_client.py
Executable file
34
tools/build_client.py
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env python2
|
||||
import os
|
||||
import sys
|
||||
|
||||
import argparse
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--build-dir', default='build',
|
||||
help='The directory of which the build was prepared.')
|
||||
parser.add_argument('--output', default='GameData.pyd',
|
||||
help='The built file.')
|
||||
parser.add_argument('--main-module', default='toontown.toonbase.ClientStart',
|
||||
help='The module to load at the start of the game.')
|
||||
parser.add_argument('modules', nargs='*', default=['otp', 'toontown'],
|
||||
help='The Toontown Stride modules to be included in the build.')
|
||||
args = parser.parse_args()
|
||||
|
||||
print 'Building the client...'
|
||||
|
||||
os.chdir(args.build_dir)
|
||||
|
||||
cmd = sys.executable + ' -m direct.showutil.pfreeze'
|
||||
args.modules.extend(['direct', 'pandac'])
|
||||
for module in args.modules:
|
||||
cmd += ' -i %s.*.*' % module
|
||||
cmd += ' -i encodings.*'
|
||||
cmd += ' -i base64'
|
||||
cmd += ' -i site'
|
||||
cmd += ' -o ' + args.output
|
||||
cmd += ' ' + args.main_module
|
||||
os.system(cmd)
|
||||
|
||||
print 'Done building the client.'
|
|
@ -1,14 +0,0 @@
|
|||
import urllib2
|
||||
|
||||
def executeHttpRequest(url, agent, **extras):
|
||||
request = urllib2.Request('http://127.0.0.1:45749/' + url)
|
||||
request.add_header('User-Agent', 'TTS-' + agent)
|
||||
request.add_header('Secret-Key', '1X5oN69^#0^fCw7s#uyQTWYJ!8m9z!6Midphf90gMQYl*L5Uy!Ri5KTP6@BbZ5#Tlm37bJAI')
|
||||
for k, v in extras.items():
|
||||
request.add_header(k, v)
|
||||
try:
|
||||
return urllib2.urlopen(request).read()
|
||||
except:
|
||||
return None
|
||||
|
||||
print executeHttpRequest('ban', 'Game', username='dev', enddate=1428408418062, comment='asshole')
|
11
tools/final_dev_client_pyd_build.bat
Executable file
11
tools/final_dev_client_pyd_build.bat
Executable file
|
@ -0,0 +1,11 @@
|
|||
@echo off
|
||||
rem NOTE: This must be run from the visual c++ 2008 32 bit command prompt!
|
||||
set PPYTHON_PATH="C:/Panda3D-1.9.0/python/ppython.exe"
|
||||
echo ppython path: %PPYTHON_PATH%
|
||||
%PPYTHON_PATH% prepare_client.py --distribution dev
|
||||
echo Preparing client done!
|
||||
echo Time to build client.
|
||||
%PPYTHON_PATH% build_client.py --main-module toontown.toonbase.ClientStartRemoteDB
|
||||
rem ClientStartRemoteDB requires ttsUsername and ttsPassword
|
||||
echo Done! The PYD is in /build/GameData.pyd.
|
||||
pause
|
|
@ -1,16 +0,0 @@
|
|||
import urllib2
|
||||
|
||||
def executeHttpRequest(url, agent, **extras):
|
||||
request = urllib2.Request('http://127.0.0.1:45749/' + url)
|
||||
request.add_header('User-Agent', 'TTS-' + agent)
|
||||
request.add_header('Secret-Key', '1X5oN69^#0^fCw7s#uyQTWYJ!8m9z!6Midphf90gMQYl*L5Uy!Ri5KTP6@BbZ5#Tlm37bJAI')
|
||||
for k, v in extras.items():
|
||||
request.add_header(k, v)
|
||||
try:
|
||||
return urllib2.urlopen(request).read()
|
||||
except:
|
||||
return None
|
||||
|
||||
print executeHttpRequest('register', 'Site', ip='69.69.69.63', username='Swag', password='user', email='swag@79.net', accesslevel=0)
|
||||
print executeHttpRequest('email', 'Site', email='swag@79.net')
|
||||
print executeHttpRequest('login', 'Site', username='Swag', password='user')
|
172
tools/prepare_client.py
Executable file
172
tools/prepare_client.py
Executable file
|
@ -0,0 +1,172 @@
|
|||
#!/usr/bin/env python2
|
||||
import argparse
|
||||
import hashlib
|
||||
import os
|
||||
from pandac.PandaModules import *
|
||||
import shutil
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--distribution', default='en',
|
||||
help='The distribution string.')
|
||||
parser.add_argument('--build-dir', default='build',
|
||||
help='The directory in which to store the build files.')
|
||||
parser.add_argument('--src-dir', default='..',
|
||||
help='The directory of the Toontown Stride source code.')
|
||||
parser.add_argument('--server-ver', default='tts-dev',
|
||||
help='The server version of this build.')
|
||||
parser.add_argument('--build-mfs', action='store_true',
|
||||
help='When present, the resource multifiles will be built.')
|
||||
parser.add_argument('--resources-dir', default='../resources',
|
||||
help='The directory of the Toontown Stride resources.')
|
||||
parser.add_argument('--config-dir', default='../config/release',
|
||||
help='The directory of the Toontown Stride configuration files.')
|
||||
parser.add_argument('--include', '-i', action='append',
|
||||
help='Explicitly include this file in the build.')
|
||||
parser.add_argument('--exclude', '-x', action='append',
|
||||
help='Explicitly exclude this file from the build.')
|
||||
parser.add_argument('--vfs', action='append',
|
||||
help='Add this file to the virtual file system at runtime.')
|
||||
parser.add_argument('modules', nargs='*', default=['otp', 'toontown'],
|
||||
help='The Toontown modules to be included in the build.')
|
||||
args = parser.parse_args()
|
||||
|
||||
print 'Preparing the client...'
|
||||
|
||||
# Create a clean directory to store the build files in:
|
||||
if os.path.exists(args.build_dir):
|
||||
shutil.rmtree(args.build_dir)
|
||||
os.mkdir(args.build_dir)
|
||||
print 'Build directory = ' + args.build_dir
|
||||
|
||||
# Copy the provided Toontown Stride modules:
|
||||
|
||||
|
||||
def minify(f):
|
||||
"""
|
||||
Returns the "minified" file data with removed __debug__ code blocks.
|
||||
"""
|
||||
|
||||
data = ''
|
||||
|
||||
debugBlock = False # Marks when we're in a __debug__ code block.
|
||||
elseBlock = False # Marks when we're in an else code block.
|
||||
|
||||
# The number of spaces in which the __debug__ condition is indented:
|
||||
indentLevel = 0
|
||||
|
||||
for line in f:
|
||||
thisIndentLevel = len(line) - len(line.lstrip())
|
||||
if ('if __debug__:' not in line) and (not debugBlock):
|
||||
data += line
|
||||
continue
|
||||
elif 'if __debug__:' in line:
|
||||
debugBlock = True
|
||||
indentLevel = thisIndentLevel
|
||||
continue
|
||||
if thisIndentLevel <= indentLevel:
|
||||
if 'else' in line:
|
||||
elseBlock = True
|
||||
continue
|
||||
if 'elif' in line:
|
||||
line = line[:thisIndentLevel] + line[thisIndentLevel+2:]
|
||||
data += line
|
||||
debugBlock = False
|
||||
elseBlock = False
|
||||
indentLevel = 0
|
||||
continue
|
||||
if elseBlock:
|
||||
data += line[4:]
|
||||
|
||||
return data
|
||||
|
||||
|
||||
for module in args.modules:
|
||||
print 'Writing module...', module
|
||||
for root, folders, files in os.walk(os.path.join(args.src_dir, module)):
|
||||
outputDir = root.replace(args.src_dir, args.build_dir)
|
||||
if not os.path.exists(outputDir):
|
||||
os.mkdir(outputDir)
|
||||
for filename in files:
|
||||
if args.include is not None and filename not in args.include:
|
||||
if not filename.endswith('.py'):
|
||||
continue
|
||||
if filename.endswith('UD.py'):
|
||||
continue
|
||||
if filename.endswith('AI.py'):
|
||||
continue
|
||||
if filename in args.exclude:
|
||||
continue
|
||||
with open(os.path.join(root, filename), 'r') as f:
|
||||
data = minify(f)
|
||||
with open(os.path.join(outputDir, filename), 'w') as f:
|
||||
f.write(data)
|
||||
|
||||
# Let's write game_data.py now. game_data.py is a compile-time generated
|
||||
# collection of data that will be used by the game at runtime. It contains the
|
||||
# PRC file data, and (stripped) DC file:
|
||||
|
||||
# First, we need to add the configuration pages:
|
||||
configData = []
|
||||
with open('../config/general.prc') as f:
|
||||
configData.append(f.read())
|
||||
|
||||
configFileName = args.distribution + '.prc'
|
||||
configFilePath = os.path.join(args.config_dir, configFileName)
|
||||
print 'Using configuration file: ' + configFilePath
|
||||
|
||||
with open(configFilePath) as f:
|
||||
data = f.readlines()
|
||||
|
||||
# Replace server-version definitions with the desired server version:
|
||||
for i, line in enumerate(data):
|
||||
if 'server-version' in line:
|
||||
data[i] = 'server-version ' + args.server_ver
|
||||
|
||||
# Add our virtual file system data:
|
||||
data.append('\n# Virtual file system...\nmodel-path /\n')
|
||||
if args.vfs is not None:
|
||||
for filepath in args.vfs:
|
||||
data.append('vfs-mount %s /\n' % filepath)
|
||||
|
||||
configData.append('\n'.join(data))
|
||||
|
||||
# Next, we need the DC file:
|
||||
dcData = ''
|
||||
filepath = os.path.join(args.src_dir, 'astron/dclass')
|
||||
for filename in os.listdir(filepath):
|
||||
if filename.endswith('.dc'):
|
||||
fullpath = str(Filename.fromOsSpecific(os.path.join(filepath, filename)))
|
||||
print 'Reading %s...' % fullpath
|
||||
with open(fullpath, 'r') as f:
|
||||
data = f.read()
|
||||
for line in data.split('\n'):
|
||||
if 'import' in line:
|
||||
data = data.replace(line + '\n', '')
|
||||
dcData += data
|
||||
|
||||
# Finally, write our data to game_data.py:
|
||||
print 'Writing game_data.py...'
|
||||
gameData = 'CONFIG = %r\nDC = %r\n'
|
||||
with open(os.path.join(args.build_dir, 'game_data.py'), 'wb') as f:
|
||||
f.write(gameData % (configData, dcData.strip()))
|
||||
|
||||
# We have all of the code gathered together. Let's create the multifiles now:
|
||||
if args.build_mfs:
|
||||
print 'Building multifiles...'
|
||||
dest = os.path.join(args.build_dir, 'resources')
|
||||
if not os.path.exists(dest):
|
||||
os.mkdir(dest)
|
||||
dest = os.path.realpath(dest)
|
||||
os.chdir(args.resources_dir)
|
||||
for phase in os.listdir('.'):
|
||||
if not phase.startswith('phase_'):
|
||||
continue
|
||||
if not os.path.isdir(phase):
|
||||
continue
|
||||
filename = phase + '.mf'
|
||||
print 'Writing...', filename
|
||||
filepath = os.path.join(dest, filename)
|
||||
os.system('multify -c -f "%s" "%s"' % (filepath, phase))
|
||||
|
||||
print 'Done preparing the client.'
|
Loading…
Reference in a new issue