Revert "12/21 modernizations from TG live"
This commit is contained in:
@@ -1,226 +0,0 @@
|
||||
|
||||
#define A_BIG_NUMBER 9999999
|
||||
#define STATE_COUNT_NORMAL 4
|
||||
#define STATE_COUNT_DIAGONAL 7
|
||||
|
||||
|
||||
/mob/verb/ChooseDMI(dmi as file)
|
||||
var/dmifile = file(dmi)
|
||||
if(isfile(dmifile) && (copytext("[dmifile]",-4) == ".dmi"))
|
||||
SliceNDice(dmifile)
|
||||
else
|
||||
world << "\red Bad DMI file '[dmifile]'"
|
||||
|
||||
|
||||
/proc/SliceNDice(dmifile as file)
|
||||
var/icon/sourceIcon = icon(dmifile)
|
||||
var/list/states = sourceIcon.IconStates()
|
||||
world << "<B>[dmifile] - states: [states.len]</B>"
|
||||
|
||||
switch(states.len)
|
||||
if(0 to (STATE_COUNT_NORMAL - 1))
|
||||
var/cont = alert(usr, "Too few states: [states.len], expected [STATE_COUNT_NORMAL] (Non-Diagonal) or [STATE_COUNT_DIAGONAL] (Diagonal), Continue?", "Unexpected Amount of States", "Yes", "No")
|
||||
if(cont == "No")
|
||||
return
|
||||
if(STATE_COUNT_NORMAL)
|
||||
world << "4 States, running in Non-Diagonal mode"
|
||||
if(STATE_COUNT_DIAGONAL)
|
||||
world << "5 States, running in Diagonal mode"
|
||||
if((STATE_COUNT_DIAGONAL + 1) to A_BIG_NUMBER)
|
||||
var/cont = alert(usr, "Too many states: [states.len], expected [STATE_COUNT_NORMAL] (Non-Diagonal) or [STATE_COUNT_DIAGONAL] (Diagonal), Continue?", "Unexpected Amount of States", "Yes", "No")
|
||||
if(cont == "No")
|
||||
return
|
||||
|
||||
|
||||
var/icon/outputIcon = new /icon()
|
||||
|
||||
var/filename = "[copytext("[dmifile]", 1, -4)]-smooth.dmi"
|
||||
fdel(filename) //force refresh
|
||||
|
||||
for(var/state in states)
|
||||
var/statename = lowertext(state)
|
||||
outputIcon = icon(filename) //open the icon again each iteration, to work around byond memory limits
|
||||
|
||||
switch(statename)
|
||||
if("box")
|
||||
var/icon/box = icon(sourceIcon, state)
|
||||
|
||||
var/icon/corner1i = icon(box)
|
||||
corner1i.DrawBox(null, 1, 1, 32, 16)
|
||||
corner1i.DrawBox(null, 17, 1, 32, 32)
|
||||
outputIcon.Insert(corner1i, "1-i")
|
||||
|
||||
var/icon/corner2i = icon(box)
|
||||
corner2i.DrawBox(null, 1, 1, 16, 32)
|
||||
corner2i.DrawBox(null, 17, 1, 32, 16)
|
||||
outputIcon.Insert(corner2i, "2-i")
|
||||
|
||||
var/icon/corner3i = icon(box)
|
||||
corner3i.DrawBox(null, 1, 32, 32, 17)
|
||||
corner3i.DrawBox(null, 17, 32, 32, 1)
|
||||
outputIcon.Insert(corner3i, "3-i")
|
||||
|
||||
var/icon/corner4i = icon(box)
|
||||
corner4i.DrawBox(null, 1, 1, 16, 32)
|
||||
corner4i.DrawBox(null, 17, 17, 32, 32)
|
||||
outputIcon.Insert(corner4i, "4-i")
|
||||
|
||||
world << "Box: \icon[box] -> \icon[corner1i] \icon[corner2i] \icon[corner3i] \icon[corner4i]"
|
||||
|
||||
if("line")
|
||||
var/icon/line = icon(sourceIcon, state)
|
||||
|
||||
//Vertical
|
||||
var/icon/line1n = icon(line)
|
||||
line1n.DrawBox(null, 1, 1, 32, 16)
|
||||
line1n.DrawBox(null, 17, 1, 32, 32)
|
||||
outputIcon.Insert(line1n, "1-n")
|
||||
|
||||
var/icon/line2n = icon(line)
|
||||
line2n.DrawBox(null, 1, 1, 16, 32)
|
||||
line2n.DrawBox(null, 17, 1, 32, 16)
|
||||
outputIcon.Insert(line2n, "2-n")
|
||||
|
||||
var/icon/line3s = icon(line)
|
||||
line3s.DrawBox(null, 1, 32, 32, 17)
|
||||
line3s.DrawBox(null, 17, 32, 32, 1)
|
||||
outputIcon.Insert(line3s, "3-s")
|
||||
|
||||
var/icon/line4s = icon(line)
|
||||
line4s.DrawBox(null, 1, 1, 16, 32)
|
||||
line4s.DrawBox(null, 17, 17, 32, 32)
|
||||
outputIcon.Insert(line4s, "4-s")
|
||||
|
||||
//Horizontal
|
||||
var/icon/line1w = icon(line3s) //Correct
|
||||
line1w.Turn(90)
|
||||
outputIcon.Insert(line1w, "1-w")
|
||||
|
||||
var/icon/line2e = icon(line1n)
|
||||
line2e.Turn(90)
|
||||
outputIcon.Insert(line2e, "2-e")
|
||||
|
||||
var/icon/line3w = icon(line4s)
|
||||
line3w.Turn(90)
|
||||
outputIcon.Insert(line3w, "3-w")
|
||||
|
||||
var/icon/line4e = icon(line2n)
|
||||
line4e.Turn(90)
|
||||
outputIcon.Insert(line4e, "4-e")
|
||||
|
||||
world << "Line: \icon[line] -> \icon[line1n] \icon[line2n] \icon[line3s] \icon[line4s] \icon[line1w] \icon[line2e] \icon[line3w] \icon[line4e]"
|
||||
|
||||
if("center_4")
|
||||
var/icon/center4 = icon(sourceIcon, state)
|
||||
|
||||
var/icon/corner1nw = icon(center4)
|
||||
corner1nw.DrawBox(null, 1, 1, 32, 16)
|
||||
corner1nw.DrawBox(null, 17, 1, 32, 32)
|
||||
outputIcon.Insert(corner1nw, "1-nw")
|
||||
|
||||
var/icon/corner2ne = icon(center4)
|
||||
corner2ne.DrawBox(null, 1, 1, 16, 32)
|
||||
corner2ne.DrawBox(null, 17, 1, 32, 16)
|
||||
outputIcon.Insert(corner2ne, "2-ne")
|
||||
|
||||
var/icon/corner3sw = icon(center4)
|
||||
corner3sw.DrawBox(null, 1, 32, 32, 17)
|
||||
corner3sw.DrawBox(null, 17, 32, 32, 1)
|
||||
outputIcon.Insert(corner3sw, "3-sw")
|
||||
|
||||
var/icon/corner4se = icon(center4)
|
||||
corner4se.DrawBox(null, 1, 1, 16, 32)
|
||||
corner4se.DrawBox(null, 17, 17, 32, 32)
|
||||
outputIcon.Insert(corner4se, "4-se")
|
||||
|
||||
world << "Center4: \icon[center4] -> \icon[corner1nw] \icon[corner2ne] \icon[corner3sw] \icon[corner4se]"
|
||||
|
||||
if("center_8")
|
||||
var/icon/center8 = icon(sourceIcon, state)
|
||||
|
||||
var/icon/corner1f = icon(center8)
|
||||
corner1f.DrawBox(null, 1, 1, 32, 16)
|
||||
corner1f.DrawBox(null, 17, 1, 32, 32)
|
||||
outputIcon.Insert(corner1f, "1-f")
|
||||
|
||||
var/icon/corner2f = icon(center8)
|
||||
corner2f.DrawBox(null, 1, 1, 16, 32)
|
||||
corner2f.DrawBox(null, 17, 1, 32, 16)
|
||||
outputIcon.Insert(corner2f, "2-f")
|
||||
|
||||
var/icon/corner3f = icon(center8)
|
||||
corner3f.DrawBox(null, 1, 32, 32, 17)
|
||||
corner3f.DrawBox(null, 17, 32, 32, 1)
|
||||
outputIcon.Insert(corner3f, "3-f")
|
||||
|
||||
var/icon/corner4f = icon(center8)
|
||||
corner4f.DrawBox(null, 1, 1, 16, 32)
|
||||
corner4f.DrawBox(null, 17, 17, 32, 32)
|
||||
outputIcon.Insert(corner4f, "4-f")
|
||||
|
||||
world << "Center8: \icon[center8] -> \icon[corner1f] \icon[corner2f] \icon[corner3f] \icon[corner4f]"
|
||||
|
||||
if("diag")
|
||||
var/icon/diag = icon(sourceIcon, state)
|
||||
|
||||
var/icon/diagse = icon(diag) //No work
|
||||
outputIcon.Insert(diagse, "d-se")
|
||||
|
||||
var/icon/diagsw = icon(diag)
|
||||
diagsw.Turn(90)
|
||||
outputIcon.Insert(diagsw, "d-sw")
|
||||
|
||||
var/icon/diagne = icon(diag)
|
||||
diagne.Turn(-90)
|
||||
outputIcon.Insert(diagne, "d-ne")
|
||||
|
||||
var/icon/diagnw = icon(diag)
|
||||
diagnw.Turn(180)
|
||||
outputIcon.Insert(diagnw, "d-nw")
|
||||
|
||||
world << "Diag: \icon[diag] -> \icon[diagse] \icon[diagsw] \icon[diagne] \icon[diagnw]"
|
||||
|
||||
if("diag_corner_a")
|
||||
var/icon/diag_corner_a = icon(sourceIcon, state)
|
||||
|
||||
var/icon/diagse0 = icon(diag_corner_a) //No work
|
||||
outputIcon.Insert(diagse0, "d-se-0")
|
||||
|
||||
var/icon/diagsw0 = icon(diag_corner_a)
|
||||
diagsw0.Turn(90)
|
||||
outputIcon.Insert(diagsw0, "d-sw-0")
|
||||
|
||||
var/icon/diagne0 = icon(diag_corner_a)
|
||||
diagne0.Turn(-90)
|
||||
outputIcon.Insert(diagne0, "d-ne-0")
|
||||
|
||||
var/icon/diagnw0 = icon(diag_corner_a)
|
||||
diagnw0.Turn(180)
|
||||
outputIcon.Insert(diagnw0, "d-nw-0")
|
||||
|
||||
world << "Diag_Corner_A: \icon[diag_corner_a] -> \icon[diagse0] \icon[diagsw0] \icon[diagne0] \icon[diagnw0]"
|
||||
|
||||
if("diag_corner_b")
|
||||
var/icon/diag_corner_b = icon(sourceIcon, state)
|
||||
|
||||
var/icon/diagse1 = icon(diag_corner_b) //No work
|
||||
outputIcon.Insert(diagse1, "d-se-0")
|
||||
|
||||
var/icon/diagsw1 = icon(diag_corner_b)
|
||||
diagsw1.Turn(90)
|
||||
outputIcon.Insert(diagsw1, "d-sw-0")
|
||||
|
||||
var/icon/diagne1 = icon(diag_corner_b)
|
||||
diagne1.Turn(-90)
|
||||
outputIcon.Insert(diagne1, "d-ne-0")
|
||||
|
||||
var/icon/diagnw1 = icon(diag_corner_b)
|
||||
diagnw1.Turn(180)
|
||||
outputIcon.Insert(diagnw1, "d-nw-0")
|
||||
|
||||
world << "Diag_Corner_B: \icon[diag_corner_b] -> \icon[diagse1] \icon[diagsw1] \icon[diagne1] \icon[diagnw1]"
|
||||
|
||||
|
||||
|
||||
fcopy(outputIcon, filename) //Update output icon each iteration
|
||||
world << "Finished [filename]!"
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 474 B |
Binary file not shown.
|
Before Width: | Height: | Size: 253 B |
@@ -1,19 +0,0 @@
|
||||
// DM Environment file for SS13SmoothingCutter.dme.
|
||||
// All manual changes should be made outside the BEGIN_ and END_ blocks.
|
||||
// New source code should be placed in .dm files: choose File/New --> Code File.
|
||||
|
||||
// BEGIN_INTERNALS
|
||||
// END_INTERNALS
|
||||
|
||||
// BEGIN_FILE_DIR
|
||||
#define FILE_DIR .
|
||||
// END_FILE_DIR
|
||||
|
||||
// BEGIN_PREFERENCES
|
||||
#define DEBUG
|
||||
// END_PREFERENCES
|
||||
|
||||
// BEGIN_INCLUDE
|
||||
#include "Cutter.dm"
|
||||
// END_INCLUDE
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 570 B |
File diff suppressed because it is too large
Load Diff
@@ -1,102 +0,0 @@
|
||||
|
||||
# Unquoted List Association Locater and Reporter, by RemieRichards V1.0 - 26/11/16
|
||||
# list("string" = value) is valid in DM
|
||||
# unfortunately, so is list(string = value) (Notice the lack of quotes? BAD BAD, it conflicts with var names!)
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
from datetime import date
|
||||
|
||||
|
||||
#Climbs up from /tools/UnquotedListAssociations and along to ../code
|
||||
scan_dir = "code" #used later to truncate log file paths
|
||||
real_dir = os.path.abspath("../../"+scan_dir)
|
||||
define_dict = {}
|
||||
total_unquoted_list_associations = 0
|
||||
log_output = True #Set to false for mad speeeeeed (slightly faster because no text output to the window, but still full log files)
|
||||
|
||||
|
||||
#Scan a directory, scanning any dm files it finds
|
||||
def unquoted_list_associations_scan_dir(scan_dir):
|
||||
global total_unquoted_list_associations
|
||||
if os.path.exists(scan_dir):
|
||||
if os.path.isdir(scan_dir):
|
||||
build_define_dictionary(scan_dir)
|
||||
|
||||
output_str = ""
|
||||
|
||||
files_scanned = 0
|
||||
files_with_named_list_args = 0
|
||||
for root, dirs, files in os.walk(scan_dir):
|
||||
for f in files:
|
||||
if log_output:
|
||||
print str(f)
|
||||
scan_result = scan_dm_file_for_unquoted_list_associations(os.path.join(root, f))
|
||||
files_scanned += 1
|
||||
if scan_result:
|
||||
output_str += scan_result+"\n"
|
||||
files_with_named_list_args += 1
|
||||
output_str += str(files_with_named_list_args) + "/" + str(files_scanned) + " files have Unquoted List Associations in them"
|
||||
output_str += "\nThere are " + str(total_unquoted_list_associations) + " total Unquoted List Associations"
|
||||
|
||||
todays_file = str(date.today())+"-unquoted_list_associations_log.txt"
|
||||
output_file = open(todays_file, "w") #w so it overrides existing files for today, there should only really be one file per day
|
||||
output_file.write(output_str)
|
||||
|
||||
|
||||
#Scan one file, returning a string as a "report" or if there are no NamedListArgs, False
|
||||
def scan_dm_file_for_unquoted_list_associations(_file):
|
||||
global total_unquoted_list_associations
|
||||
if not _file.endswith(".dm"):
|
||||
return False
|
||||
|
||||
with open(_file, "r") as dm_file:
|
||||
filecontents = dm_file.read()
|
||||
|
||||
unquoted_list_associations = []
|
||||
list_definitions = []
|
||||
|
||||
for listdef in re.findall(r"=\s*list\((.*)\)", filecontents):
|
||||
list_definitions.append(listdef)
|
||||
|
||||
listdefs = ' '.join(list_definitions)
|
||||
|
||||
for matchtuple in re.findall(r"(?:list\(|,)\s*(\w+)\s*,*\s*=\s*(\w+)", listdefs):
|
||||
if not define_dict.get(matchtuple[0], False): #defines are valid
|
||||
unquoted_list_associations.append(matchtuple)
|
||||
|
||||
count = len(unquoted_list_associations)
|
||||
|
||||
if count:
|
||||
file_report = ".."+scan_dir+str(_file).split(scan_dir)[1]+" " #crop it down to ..\code\DIR\FILE.dm, everything else is developer specific
|
||||
for nla in unquoted_list_associations:
|
||||
file_report += "\nlist(" + nla[0] + " = " + nla[1] + ")"
|
||||
total_unquoted_list_associations += count
|
||||
file_report += "\nTotal Unquoted List Associations: "+str(count)
|
||||
return file_report
|
||||
else:
|
||||
return False
|
||||
|
||||
#Build a dict of defines, such that we can rule them out as NamedListArgs
|
||||
def build_define_dictionary(scan_dir):
|
||||
define_dict = {}
|
||||
for root, dirs, files in os.walk(scan_dir):
|
||||
for f in files:
|
||||
scan_dm_file_for_defines(os.path.join(root, f))
|
||||
|
||||
|
||||
#Find all #define X Y in a file and update define_dict so that define_dict[X] = True
|
||||
def scan_dm_file_for_defines(_file):
|
||||
if not _file.endswith(".dm"):
|
||||
return False
|
||||
|
||||
with open(_file, "r") as dm_file:
|
||||
filecontents = dm_file.read()
|
||||
|
||||
for define_def in re.findall(r"#define\s+([\w()]+)[ \t]+[^\n]+", filecontents):
|
||||
define_dict[define_def] = True
|
||||
|
||||
|
||||
unquoted_list_associations_scan_dir(real_dir)
|
||||
print "Done!"
|
||||
@@ -155,14 +155,14 @@ function checkchangelog($payload, $merge = false) {
|
||||
$foundcltag = false;
|
||||
foreach ($body as $line) {
|
||||
$line = trim($line);
|
||||
if (substr($line,0,4) == ':cl:' || substr($line,0,4) == '🆑') {
|
||||
if (substr($line,0,4) == ':cl:') {
|
||||
$incltag = true;
|
||||
$foundcltag = true;
|
||||
$pos = strpos($line, " ");
|
||||
if ($pos)
|
||||
$username = substr($line, $pos+1);
|
||||
continue;
|
||||
} else if (substr($line,0,5) == '/:cl:' || substr($line,0,6) == '/ :cl:' || substr($line,0,5) == ':/cl:' || substr($line,0,5) == '/🆑' || substr($line,0,6) == '/ 🆑' ) {
|
||||
} else if (substr($line,0,5) == '/:cl:' || substr($line,0,6) == '/ :cl:' || substr($line,0,5) == ':/cl:') {
|
||||
$incltag = false;
|
||||
$changelogbody = array_merge($changelogbody, $currentchangelogblock);
|
||||
continue;
|
||||
|
||||
+4
-15
@@ -4,7 +4,6 @@ import subprocess
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
import time
|
||||
from subprocess import PIPE, STDOUT
|
||||
|
||||
null = open("/dev/null", "wb")
|
||||
@@ -37,8 +36,7 @@ def stage2(map):
|
||||
p = subprocess.Popen(args, shell=True)
|
||||
wait(p)
|
||||
|
||||
def stage3(profile_mode=False):
|
||||
start_time = time.time()
|
||||
def stage3():
|
||||
play("sound/misc/compiler-stage2.ogg")
|
||||
logfile = open('server.log~','w')
|
||||
p = subprocess.Popen(
|
||||
@@ -47,15 +45,9 @@ def stage3(profile_mode=False):
|
||||
try:
|
||||
while p.returncode is None:
|
||||
stdout = p.stdout.readline()
|
||||
if "Initializations complete." in stdout:
|
||||
t = "Initializations complete."
|
||||
if t in stdout:
|
||||
play("sound/misc/server-ready.ogg")
|
||||
time_taken = time.time() - start_time
|
||||
print("{} seconds taken to fully start".format(time_taken))
|
||||
if "Map is ready." in stdout:
|
||||
time_taken = time.time() - start_time
|
||||
print("{} seconds for initial map loading".format(time_taken))
|
||||
if profile_mode:
|
||||
return time_taken
|
||||
sys.stdout.write(stdout)
|
||||
sys.stdout.flush()
|
||||
logfile.write(stdout)
|
||||
@@ -71,7 +63,6 @@ def main():
|
||||
parser.add_argument('-s','---stage',default=1,type=int)
|
||||
parser.add_argument('--only',action='store_true')
|
||||
parser.add_argument('-m','--map',type=str)
|
||||
parser.add_argument('--profile-mode',action='store_true')
|
||||
args = parser.parse_args()
|
||||
stage = args.stage
|
||||
assert stage in (1,2,3)
|
||||
@@ -84,9 +75,7 @@ def main():
|
||||
if not args.only:
|
||||
stage = 3
|
||||
if stage == 3:
|
||||
value = stage3(profile_mode=args.profile_mode)
|
||||
with open('profile~', 'a') as f:
|
||||
f.write("{}\n".format(value))
|
||||
stage3()
|
||||
|
||||
if __name__=='__main__':
|
||||
try:
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
#Map Merger#
|
||||
Before any change to a map, it is good to use the Map Merger tools. In a nutshell, it rewrites the map to minimize differences between different versions of the map (DreamMakers map editor rewrites a lot of the tile keys). This makes the git diff between different map changes much smaller. More recently a new way of laying out the map was invented by Remie, called TGM, this helps to further reduce conflicts in the map files.
|
||||
|
||||
This is good for a few reasons
|
||||
|
||||
1) Maintainers can actually verify the changes you are making are what you say they are by simply viewing the diff (For small changes at least)
|
||||
|
||||
2) The less changes there are in any given map diff, the easier it is for git to merge it without running into unexpected conflicts, which in most cases you have to either manually resolve or require you to remap your changes
|
||||
|
||||
|
||||
However - to do all this is going to require you to put some elbow grease into understanding the map merger tool.
|
||||
|
||||
If you have difficulty using these tools, ask for help in #coderbus
|
||||
|
||||
#Using the tools#
|
||||
|
||||
##1. Install Python 3.5 or greater##
|
||||
If you don't have Python already installed it can be downloaded from: https://www.python.org/downloads/ - make sure you grab the latest python 3, again, it must be 3.5 or greater
|
||||
##2. PATH Python##
|
||||
This step is mostly applicable to windows users, you must make sure you ask the windows installer to add python to your path, [like shown in this example screenshot](https://file.house/DA6H.png)
|
||||
|
||||
If you have already installed python you may need to manually add it to your path as indicated in [this guide](http://superuser.com/questions/143119/how-to-add-python-to-the-windows-path)
|
||||
##3. Prepare Maps##
|
||||
Run "Prepare Maps.bat" in the tools/mapmerge/ directory.
|
||||
##4. Edit your map##
|
||||
Make your changes to the map here. Remember to save them!
|
||||
##5. Clean map##
|
||||
Run "Run Map Merge - TGM.bat" in the tools/mapmerge/ directory.
|
||||
##7. Check differences##
|
||||
Use your git application of choice to look at the differences between revisions of your code and commit the result.
|
||||
##8. Commit##
|
||||
Your map is now ready to be committed, rejoice and wait for conflicts.
|
||||
|
||||
#Common pitfalls#
|
||||
Open the map in dreameditor before committing the results of the mapmerger - this can cause dreameditor to resave the map back to
|
||||
dmm, if you're having issues with your map getting stuck in dmm mode, try comitting and pushing the mapmerger changes before
|
||||
reopening in dreameditor.
|
||||
@@ -1,18 +1,5 @@
|
||||
import sys
|
||||
|
||||
try:
|
||||
version = sys.version_info
|
||||
if version.major < 3 or (version.major == 3 and version.minor < 5):
|
||||
print("ERROR: You are running an incompatible version of Python. The current minimum version required is [3.5].\nYour version: {}".format(sys.version))
|
||||
sys.exit()
|
||||
except:
|
||||
print("ERROR: Something went wrong, you might be running an incompatible version of Python. The current minimum version required is [3.5].\nYour version: {}".format(sys.version))
|
||||
sys.exit()
|
||||
|
||||
import collections
|
||||
|
||||
error = {0:"OK", 1:"WARNING: Key lengths are different, all the lines change."}
|
||||
|
||||
maxx = 0
|
||||
maxy = 0
|
||||
key_length = 1
|
||||
@@ -29,21 +16,11 @@ def merge_map(newfile, backupfile, tgm):
|
||||
reset_globals()
|
||||
|
||||
shitmap = parse_map(newfile)
|
||||
originalmap = parse_map(backupfile)
|
||||
|
||||
global key_length
|
||||
if shitmap["key_length"] != originalmap["key_length"]:
|
||||
if tgm:
|
||||
write_dictionary_tgm(newfile, shitmap["dictionary"])
|
||||
write_grid_coord_small(newfile, shitmap["grid"])
|
||||
return 1
|
||||
else:
|
||||
key_length = originalmap["key_length"]
|
||||
|
||||
shitDict = shitmap["dictionary"] #key to tile data dictionary
|
||||
shitGrid = shitmap["grid"] #x,y coords to tiles (keys) dictionary (the map's layout)
|
||||
|
||||
originalDict = sort_dictionary(originalmap["dictionary"])
|
||||
|
||||
originalmap = parse_map(backupfile)
|
||||
originalDict = originalmap["dictionary"]
|
||||
originalGrid = originalmap["grid"]
|
||||
|
||||
mergeGrid = dict() #final map layout
|
||||
@@ -83,7 +60,7 @@ def merge_map(newfile, backupfile, tgm):
|
||||
try:
|
||||
unused_keys.remove(newKey)
|
||||
except ValueError: #caused by a duplicate entry
|
||||
print("NOTICE: Correcting duplicate dictionary entry. ({})".format(shitKey))
|
||||
print("WARNING: Correcting duplicate dictionary entry. ({})".format(shitKey))
|
||||
mergeGrid[x,y] = newKey
|
||||
known_keys[shitKey] = newKey
|
||||
#if data at original x,y no longer exists we reuse the key immediately
|
||||
@@ -97,6 +74,9 @@ def merge_map(newfile, backupfile, tgm):
|
||||
newKey = generate_new_key(originalDict)
|
||||
else:
|
||||
newKey = generate_new_key(tempDict)
|
||||
if newKey == "OVERFLOW": #if this happens, merging is impossible
|
||||
print("ERROR: Key overflow detected.")
|
||||
return 0
|
||||
tempGrid[x,y] = newKey
|
||||
temp_keys[shitKey] = newKey
|
||||
tempDict[newKey] = shitData
|
||||
@@ -121,6 +101,7 @@ def merge_map(newfile, backupfile, tgm):
|
||||
i += 1
|
||||
sort = 1
|
||||
|
||||
|
||||
#Recycle outdated keys with any new tile data, starting from the bottom of the dictionary
|
||||
i = 0
|
||||
for key, value in reversed(tempDict.items()):
|
||||
@@ -139,7 +120,15 @@ def merge_map(newfile, backupfile, tgm):
|
||||
|
||||
#if gaps in the key sequence were found, sort the dictionary for cleanliness
|
||||
if sort == 1:
|
||||
originalDict = sort_dictionary(originalDict)
|
||||
sorted_dict = collections.OrderedDict()
|
||||
next_key = get_next_key("")
|
||||
while len(sorted_dict) < len(originalDict):
|
||||
try:
|
||||
sorted_dict[next_key] = originalDict[next_key]
|
||||
except KeyError:
|
||||
pass
|
||||
next_key = get_next_key(next_key)
|
||||
originalDict = sorted_dict
|
||||
|
||||
if tgm:
|
||||
write_dictionary_tgm(newfile, originalDict)
|
||||
@@ -147,7 +136,7 @@ def merge_map(newfile, backupfile, tgm):
|
||||
else:
|
||||
write_dictionary(newfile, originalDict)
|
||||
write_grid(newfile, mergeGrid)
|
||||
return 0
|
||||
return 1
|
||||
|
||||
#write dictionary in tgm format
|
||||
def write_dictionary_tgm(filename, dictionary):
|
||||
@@ -240,17 +229,6 @@ def get_next_key(key):
|
||||
carry -= 1
|
||||
return new_key[::-1]
|
||||
|
||||
def sort_dictionary(dictionary):
|
||||
sorted_dict = collections.OrderedDict()
|
||||
next_key = get_next_key("")
|
||||
while len(sorted_dict) < len(dictionary):
|
||||
try:
|
||||
sorted_dict[next_key] = dictionary[next_key]
|
||||
except KeyError:
|
||||
pass
|
||||
next_key = get_next_key(next_key)
|
||||
return sorted_dict
|
||||
|
||||
#still does not support more than one z level per file, but should parse any format
|
||||
def parse_map(map_file):
|
||||
with open(map_file, "r") as map_input:
|
||||
@@ -278,10 +256,9 @@ def parse_map(map_file):
|
||||
curr_num = ""
|
||||
reading_coord = "x"
|
||||
|
||||
|
||||
global key_length
|
||||
global maxx
|
||||
global maxy
|
||||
key_length_local = 0
|
||||
curr_x = 0
|
||||
curr_y = 0
|
||||
curr_z = 1
|
||||
@@ -366,7 +343,7 @@ def parse_map(map_file):
|
||||
if in_key_block:
|
||||
if char == "\"":
|
||||
in_key_block = False
|
||||
key_length_local = len(curr_key)
|
||||
key_length = len(curr_key)
|
||||
else:
|
||||
curr_key = curr_key + char
|
||||
continue
|
||||
@@ -442,7 +419,7 @@ def parse_map(map_file):
|
||||
|
||||
|
||||
curr_key = curr_key + char
|
||||
if len(curr_key) == key_length_local:
|
||||
if len(curr_key) == key_length:
|
||||
iter_x += 1
|
||||
if iter_x > 1:
|
||||
curr_x += 1
|
||||
@@ -467,7 +444,6 @@ def parse_map(map_file):
|
||||
data = dict()
|
||||
data["dictionary"] = dictionary
|
||||
data["grid"] = grid
|
||||
data["key_length"] = key_length_local
|
||||
return data
|
||||
|
||||
#subtract keyB from keyA
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import map_helpers
|
||||
import sys
|
||||
import os
|
||||
import pathlib
|
||||
import map_helpers
|
||||
import shutil
|
||||
|
||||
#main("../../_maps/")
|
||||
@@ -47,7 +47,7 @@ def main(map_folder, tgm=0):
|
||||
print("\nMerging these maps:")
|
||||
for i in valid_indices:
|
||||
print(str(list_of_files[i])[len(map_folder):])
|
||||
merge = input("\nPress Enter to merge...\n")
|
||||
merge = input("\nPress Enter to merge...")
|
||||
if merge == "abort":
|
||||
print("\nAborted map merge.")
|
||||
sys.exit()
|
||||
@@ -57,19 +57,14 @@ def main(map_folder, tgm=0):
|
||||
shutil.copyfile(path_str, path_str + ".before")
|
||||
path_str_pretty = path_str[len(map_folder):]
|
||||
try:
|
||||
error = map_helpers.merge_map(path_str, path_str + ".backup", tgm)
|
||||
if error > 1:
|
||||
print(map_helpers.error[error])
|
||||
if map_helpers.merge_map(path_str, path_str + ".backup", tgm) != 1:
|
||||
print("ERROR MERGING: {}".format(path_str_pretty))
|
||||
os.remove(path_str + ".before")
|
||||
continue
|
||||
if error == 1:
|
||||
print(map_helpers.error[1])
|
||||
print("MERGED: {}".format(path_str_pretty))
|
||||
print(" - ")
|
||||
except FileNotFoundError:
|
||||
print("ERROR: File not found! Make sure you run 'Prepare Maps.bat' before merging.")
|
||||
print("MISSING BACKUP FILE: " + path_str_pretty + ".backup")
|
||||
print(" - ")
|
||||
print("\nERROR: File not found! Make sure you run 'Prepare Maps.bat' before merging.")
|
||||
print(path_str_pretty + " || " + path_str_pretty + ".backup")
|
||||
|
||||
print("\nFinished merging.")
|
||||
print("\nNOTICE: A version of the map files from before merging have been created for debug purposes.\nDo not delete these files until it is sure your map edits have no undesirable changes.")
|
||||
|
||||
@@ -14,7 +14,7 @@ call bin\getcurdate.bat
|
||||
cls
|
||||
echo Watch Dog.
|
||||
echo Server Running. Watching for server exits.
|
||||
start /WAIT /ABOVENORMAL "" dreamdaemon.exe gamefolder\%PROJECTNAME%.dmb -port %PORT% -trusted -public -close -log "data\logs\runtimes\runtime-%CUR_DATE%.log"
|
||||
start /WAIT /ABOVENORMAL "" dreamdaemon.exe gamefolder\%PROJECTNAME%.dmb -port %PORT% -trusted -close -log "data\logs\runtimes\runtime-%CUR_DATE%.log"
|
||||
cls
|
||||
echo Watch Dog.
|
||||
echo Server exit detected. Restarting in 60 seconds.
|
||||
|
||||
Reference in New Issue
Block a user