Start patching fun

This commit is contained in:
Christian Weeks committed 2012-03-30 13:33:29 -04:00
1 parent aed6bcc737
commit 84d4f7765c
2 files changed
+108

No files matched your search

@@ -0,0 +1,45 @@
--- ../vanillamcp/src-reference/minecraft_server/net/minecraft/server/MinecraftServer.java 0000-00-00 00:00:00.000000000 -0000
+++ ../vanillamcp/src-work/minecraft_server/net/minecraft/server/MinecraftServer.java 0000-00-00 00:00:00.000000000 -0000
@@ -13,6 +13,9 @@
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
+
+import fml.FMLHooks;
+import fml.obf.FMLHandler;
import net.minecraft.src.AnvilSaveConverter;
import net.minecraft.src.AnvilSaveHandler;
import net.minecraft.src.AxisAlignedBB;
@@ -143,6 +146,7 @@
var1.setDaemon(true);
var1.start();
ConsoleLogManager.init();
+ FMLHandler.INSTANCE.onPreLoad(this);
logger.info("Starting minecraft server version 1.2.4");
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L)
@@ -190,6 +194,8 @@
logger.warning("To change this, set \"online-mode\" to \"true\" in the server.settings file.");
}
+ FMLHandler.INSTANCE.onLoadComplete();
+
this.configManager = new ServerConfigurationManager(this);
this.entityTracker[0] = new EntityTracker(this, 0);
this.entityTracker[1] = new EntityTracker(this, -1);
@@ -433,6 +439,7 @@
var3 += var7;
var1 = var5;
+ FMLHandler.INSTANCE.onPreTick();
if (this.worldMngr[0].isAllPlayersFullyAsleep())
{
this.doTick();
@@ -446,6 +453,7 @@
this.doTick();
}
}
+ FMLHandler.INSTANCE.onPostTick();
}
}
else
+63
View File
@@ -0,0 +1,63 @@
import sys
import os
import commands
import fnmatch
import re
import subprocess, shlex
def cmdsplit(args):
if os.sep == '\\':
args = args.replace('\\', '\\\\')
return shlex.split(args)
def cleanDirs(path):
if not os.path.isdir(path):
return
files = os.listdir(path)
if len(files):
for f in files:
fullpath = os.path.join(path, f)
if os.path.isdir(fullpath):
cleanDirs(fullpath)
files = os.listdir(path)
if len(files) == 0:
os.rmdir(path)
def main():
print("Creating patches")
base = os.path.normpath(os.path.join(sys.argv[1], 'src-reference'))
work = os.path.normpath(os.path.join(sys.argv[1], 'src-work'))
timestamp = re.compile(r'[0-9-]* [0-9:\.]* [+-][0-9]*\r?\n')
for path, _, filelist in os.walk(work, followlinks=True):
for cur_file in fnmatch.filter(filelist, '*.java'):
file_base = os.path.normpath(os.path.join(base, path[len(work)+1:], cur_file))
file_work = os.path.normpath(os.path.join(work, path[len(work)+1:], cur_file))
patch = ''
cmd = 'diff -u %s %s -r --strip-trailing-cr --new-file' % (file_base, file_work)
process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
patch, _ = process.communicate()
patch_dir = os.path.join(sys.argv[2]+'patches', path[len(work)+1:])
patch_file = os.path.join(patch_dir, cur_file + '.patch')
if len(patch) > 0:
print patch_file
patch = timestamp.sub("0000-00-00 00:00:00.000000000 -0000\n", patch)
patch = patch.replace('\r\n', '\n')
if not os.path.exists(patch_dir):
os.makedirs(patch_dir)
with open(patch_file, 'w') as fh:
fh.write(patch)
else:
if os.path.isfile(patch_file):
print("Deleting empty patch: %s"%(patch_file))
os.remove(patch_file)
cleanDirs('patches')
if __name__ == '__main__':
main()