12/21 modernizations from TG live (#103)

* sync (#3)

* shuttle auto call

* Merge /vore into /master (#39)

* progress

* Compile errors fixed

No idea if it's test worthy tho as conflicts with race overhaul and
narky removal.

* Update admins.txt

* efforts continue

Fuck grab code, seriously

* grab code is cancer

* Execute the Narkism

Do not hesitate.

Show no mercy.

* holy shit grab code is awful

* have I bitched about grab code

My bitching, let me show you it

* código de agarre es una mierda

No really it is

* yeah I don't even know anymore.

* Lolnope. Fuck grab code

* I'm not even sure what to fix anymore

* Self eating is not an acceptable fate

* Taste the void, son.

* My code doesn't pass it's own sanity check.

Maybe it's a sign of things to come.

* uncommented and notes

* It Works and I Don't Know Why (#38)

* shuttle auto call

* it works and I don't know why

* Subsystem 12/21

Most Recent TG subsystem folder

* globalvars 12/21

Tossed out the flavor_misc and parallax files

* Onclick 12/21

as well as .dme updates

* _defines 12/21

ommited old _MC.dm

* _HELPERS 12/21

Preserved snowflake placement of furry sprites

* _defeines/genetics

reapplied narkism holdover for snowflake races.

* Oops forgot mutant colors

* modules porting 12/21 + Sounds/icons

Admin, Client and most of mob life files ommitted

* enviroment file

* Admin optimizations

ahelp log system kept

* Mob ports 12/21

Flavor text preserved

* datums ported 12/21

* Game ported 12/21

* batch of duplicate fixes/dogborg work

Dogborgs need to be modernized to refractored borg standards.

* moar fixes

* Maps and futher compile fixes
This commit is contained in:
Poojawa
2016-12-22 03:57:55 -06:00
committed by GitHub
parent f5e143a452
commit cf59ac1c3d
2215 changed files with 707445 additions and 87041 deletions

View File

@@ -1,5 +1,18 @@
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
@@ -16,11 +29,21 @@ 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)
originalmap = parse_map(backupfile)
originalDict = originalmap["dictionary"]
originalDict = sort_dictionary(originalmap["dictionary"])
originalGrid = originalmap["grid"]
mergeGrid = dict() #final map layout
@@ -60,7 +83,7 @@ def merge_map(newfile, backupfile, tgm):
try:
unused_keys.remove(newKey)
except ValueError: #caused by a duplicate entry
print("WARNING: Correcting duplicate dictionary entry. ({})".format(shitKey))
print("NOTICE: 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
@@ -74,9 +97,6 @@ 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
@@ -101,7 +121,6 @@ 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()):
@@ -120,15 +139,7 @@ def merge_map(newfile, backupfile, tgm):
#if gaps in the key sequence were found, sort the dictionary for cleanliness
if sort == 1:
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
originalDict = sort_dictionary(originalDict)
if tgm:
write_dictionary_tgm(newfile, originalDict)
@@ -136,7 +147,7 @@ def merge_map(newfile, backupfile, tgm):
else:
write_dictionary(newfile, originalDict)
write_grid(newfile, mergeGrid)
return 1
return 0
#write dictionary in tgm format
def write_dictionary_tgm(filename, dictionary):
@@ -229,6 +240,17 @@ 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:
@@ -256,9 +278,10 @@ 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
@@ -343,7 +366,7 @@ def parse_map(map_file):
if in_key_block:
if char == "\"":
in_key_block = False
key_length = len(curr_key)
key_length_local = len(curr_key)
else:
curr_key = curr_key + char
continue
@@ -419,7 +442,7 @@ def parse_map(map_file):
curr_key = curr_key + char
if len(curr_key) == key_length:
if len(curr_key) == key_length_local:
iter_x += 1
if iter_x > 1:
curr_x += 1
@@ -444,6 +467,7 @@ 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