From 49385961d912b428007918690ca24f29b4dd73af Mon Sep 17 00:00:00 2001 From: LexManos Date: Fri, 10 Aug 2012 18:25:11 -0700 Subject: [PATCH] Updated conf merger script to just merge everything, and normalize the line endings so git doesn't complain. --- fml/conf/methods.csv | 10 ++++---- fml/conf/params.csv | 38 +++++++++++++++---------------- fml/install/fml.py | 54 +++++++++++++++++++++++--------------------- 3 files changed, 52 insertions(+), 50 deletions(-) diff --git a/fml/conf/methods.csv b/fml/conf/methods.csv index 5b2c88072..71738dc70 100644 --- a/fml/conf/methods.csv +++ b/fml/conf/methods.csv @@ -1,9 +1,4 @@ searge,name,side,desc -func_74611_a,getStringValue,0,Gets a String by navigating the hierarchy below this node. -func_74612_b,getArrayNode,0,"Gets a List of JsonNodes, representing a JSON array, by navigating the hierarchy below this node." -func_74614_d,getFields,0,return the fields associated with this node -func_74615_c,getText,0, -func_74789_a,parse,0,Parse the specified JSON String func_70000_a,addServerStatsToSnooper,2, func_70001_b,addServerTypeToSnooper,2, func_70002_Q,isSnooperEnabled,2,Returns whether snooping is enabled or not. @@ -1894,7 +1889,11 @@ func_74603_a,withElement,2,Adds the given element to the array that will be buil func_74604_a,build,2, func_74608_a,withFieldBuilder,2, func_74610_b,getElements,2, +func_74611_a,getStringValue,2,Gets a String by navigating the hierarchy below this node. +func_74612_b,getArrayNode,2,"Gets a List of JsonNodes, representing a JSON array, by navigating the hierarchy below this node." func_74613_a,wrapExceptionsFor,2, +func_74614_d,getFields,2,return the fields associated with this node +func_74615_c,getText,2, func_74616_a,getType,2, func_74618_a,asList,2, func_74628_a,shortForm,2, @@ -1991,6 +1990,7 @@ func_74785_a,format,2, func_74786_a,formatJsonNode,2, func_74787_a,format,2, func_74788_a,parse,2,Parse the character stream from the specified Reader into a JsonRootNode object. +func_74789_a,parse,2,Parse the specified JSON String func_74792_a,decompress,2, func_74793_a,safeWrite,2, func_74794_a,read,2,Reads from a CompressedStream. diff --git a/fml/conf/params.csv b/fml/conf/params.csv index 0fd80b3b0..21d0b7279 100644 --- a/fml/conf/params.csv +++ b/fml/conf/params.csv @@ -1,23 +1,4 @@ param,name,side -p_79000_1_,par1IUpdatePlayerListBox,1 -p_79003_0_,par0DedicatedServer,1 -p_79004_0_,par0ServerGUI,1 -p_79013_0_,par0GuiStatsComponent,1 -p_79015_1_,par1ArrayOfLong,1 -p_actionPerformed_1_,par1ActionEvent,1 -p_focusGained_1_,par1FocusEvent,1 -p_i4100_1_,par1DedicatedServer,1 -p_i4101_1_,par1GuiLogOutputHandler,1 -p_i4102_1_,par1JTextArea,1 -p_i4103_1_,par1MinecraftServer,1 -p_i4104_1_,par1ServerGUI,1 -p_i4104_2_,par2JTextField,1 -p_i4105_1_,par1MinecraftServer,1 -p_i4106_1_,par1DedicatedServer,1 -p_i4107_1_,par1ServerGUI,1 -p_i4108_1_,par1DedicatedServer,1 -p_i4109_1_,par1GuiStatsComponent,1 -p_publish_1_,par1LogRecord,1 p_70000_1_,par1PlayerUsageSnooper,2 p_70001_1_,par1PlayerUsageSnooper,2 p_70003_1_,par1Str,2 @@ -6534,8 +6515,14 @@ p_78944_1_,par1WorldRenderer,2 p_78944_2_,par2WorldRenderer,2 p_78946_1_,par1WorldRenderer,2 p_78946_2_,par2WorldRenderer,2 +p_79000_1_,par1IUpdatePlayerListBox,2 +p_79003_0_,par0DedicatedServer,2 +p_79004_0_,par0ServerGUI,2 +p_79013_0_,par0GuiStatsComponent,2 +p_79015_1_,par1ArrayOfLong,2 p_accept_1_,par1File,2 p_accept_2_,par2Str,2 +p_actionPerformed_1_,par1ActionEvent,2 p_appletResize_1_,par1,2 p_appletResize_2_,par2,2 p_compareTo_1_,par1Obj,2 @@ -6544,6 +6531,7 @@ p_compare_2_,par2Obj,2 p_containsKey_1_,par1Obj,2 p_containsValue_1_,par1Obj,2 p_equals_1_,par1Obj,2 +p_focusGained_1_,par1FocusEvent,2 p_format_1_,par1LogRecord,2 p_getArrayNode_1_,par1ArrayOfObj,2 p_getParameter_1_,par1Str,2 @@ -9124,12 +9112,24 @@ p_i4048_1_,par1Str,2 p_i4049_1_,par1Str,2 p_i4049_2_,par2Str,2 p_i4050_1_,par1BouncyCastleProvider,2 +p_i4100_1_,par1DedicatedServer,2 +p_i4101_1_,par1GuiLogOutputHandler,2 +p_i4102_1_,par1JTextArea,2 +p_i4103_1_,par1MinecraftServer,2 +p_i4104_1_,par1ServerGUI,2 +p_i4104_2_,par2JTextField,2 +p_i4105_1_,par1MinecraftServer,2 +p_i4106_1_,par1DedicatedServer,2 +p_i4107_1_,par1ServerGUI,2 +p_i4108_1_,par1DedicatedServer,2 +p_i4109_1_,par1GuiStatsComponent,2 p_implies_1_,par1Permission,2 p_init_1_,par1,2 p_init_2_,par2CipherParameters,2 p_main_0_,par0ArrayOfStr,2 p_paint_1_,par1Graphics,2 p_parse_1_,par1Str,2 +p_publish_1_,par1LogRecord,2 p_putAll_1_,par1Map,2 p_put_1_,par1Obj,2 p_put_2_,par2Obj,2 diff --git a/fml/install/fml.py b/fml/install/fml.py index 97b830939..2d6d9a448 100644 --- a/fml/install/fml.py +++ b/fml/install/fml.py @@ -218,11 +218,6 @@ def setup_fml(fml_dir, mcp_dir): updatemd5_side(commands, CLIENT) updatemd5_side(commands, SERVER) reset_logger() - - #Delete /common/cpw to get rid of the Side/SideOnly classes used in decompilation - cpw_dir = os.path.join(mcp_dir, 'src', 'common', 'cpw') - if os.path.isdir(cpw_dir): - shutil.rmtree(cpw_dir) os.chdir(fml_dir) @@ -273,6 +268,11 @@ def apply_fml_patches(fml_dir, mcp_dir, src_dir, copy_files=True): has_client = os.path.isdir(os.path.join(src_dir, 'minecraft')) has_server = os.path.isdir(os.path.join(src_dir, 'minecraft_server')) + #Delete /common/cpw to get rid of the Side/SideOnly classes used in decompilation + cpw_dir = os.path.join(src_dir, 'common', 'cpw') + if os.path.isdir(cpw_dir): + shutil.rmtree(cpw_dir) + #patch files print 'Applying Forge ModLoader patches' sys.stdout.flush() @@ -527,8 +527,17 @@ def setup_mcp(fml_dir, mcp_dir, dont_gen_conf=True): #update workspace print 'Fixing MCP Workspace' merge_tree(os.path.join(fml_dir, 'eclipse'), os.path.join(mcp_dir, 'eclipse')) - - + +def normaliselines(in_filename): + in_filename = os.path.normpath(in_filename) + tmp_filename = in_filename + '.tmp' + + with open(in_filename, 'rb') as in_file: + with open(tmp_filename, 'wb') as out_file: + out_file.write(in_file.read().replace('\r\n', '\n')) + + shutil.move(tmp_filename, in_filename) + def get_conf_copy(mcp_dir, fml_dir): #Lets grab the files we dont work on for file in ['astyle.cfg', 'version.cfg', 'patches/minecraft_ff.patch', 'patches/minecraft_server_ff.patch', 'newids.csv']: @@ -539,6 +548,7 @@ def get_conf_copy(mcp_dir, fml_dir): if os.path.exists(dst_file): os.remove(dst_file) shutil.copy(src_file, dst_file) + normaliselines(dst_file) print 'Grabbing: ' + src_file ff_server = os.path.normpath(os.path.join(fml_dir, 'conf', 'patches', 'minecraft_server_ff.patch')) @@ -558,7 +568,7 @@ def get_conf_copy(mcp_dir, fml_dir): ' int var4 = p_77874_1_.func_72841_b("map");' ] os.remove(ff_server) - with open(ff_server, 'w') as f: + with open(ff_server, 'wb') as f: for line in data: f.write(line.rstrip('\r\n') + '\n') @@ -615,7 +625,7 @@ def gen_merged_srg(mcp_dir, fml_dir): common[type][key] = value #+ ' #S' #Print joined retroguard files - with open(os.path.join(fml_dir, 'conf', 'joined.srg'), 'w') as f: + with open(os.path.join(fml_dir, 'conf', 'joined.srg'), 'wb') as f: for type in ['PK:', 'CL:', 'FD:', 'MD:']: for key in sorted(common[type]): f.write('%s %s %s\n' % (type, key, common[type][key])) @@ -660,7 +670,7 @@ def gen_merged_exc(mcp_dir, fml_dir): joined = dict(common.items() + server.items()) #Print joined mcinjector files - with open(os.path.join(fml_dir, 'conf', 'joined.exc'), 'w') as f: + with open(os.path.join(fml_dir, 'conf', 'joined.exc'), 'wb') as f: for key in sorted(joined): f.write('%s=%s\n' % (key, joined[key])) @@ -699,22 +709,14 @@ def gen_shared_searge_names(common_srg, common_exc): def gen_merged_csv(common_map, in_file, out_file, main_key='searge'): reader = csv.DictReader(open(in_file, 'r')) print 'Generating merged csv for %s' % os.path.basename(in_file) - sides = {'client': [], 'server': [], 'common': []} + common = [] added = [] for row in reader: - side = int(row['side']) - if row[main_key] in common_map: - if not row[main_key] in added: - row['side'] = '2' - sides['common'].append(row) - added.append(row[main_key]) - elif side == 0: - sides['client'].append(row) - else: - sides['server'].append(row) - - writer = csv.DictWriter(open(out_file, 'wb'), fieldnames=reader.fieldnames) + if not row[main_key] in added: + row['side'] = '2' + common.append(row) + added.append(row[main_key]) + writer = csv.DictWriter(open(out_file, 'wb'), fieldnames=reader.fieldnames, lineterminator='\n') writer.writeheader() - for key in ['client', 'server', 'common']: - for row in sorted(sides[key], key=lambda row: row[main_key]): - writer.writerow(row) + for row in sorted(common, key=lambda row: row[main_key]): + writer.writerow(row)