Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions modloader/modconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from urllib2 import urlopen
import json
from cStringIO import StringIO
from collections import namedtuple
import zipfile

import renpy
Expand Down Expand Up @@ -56,6 +57,7 @@ def report_exception(overview, error_str):
#steammgr.HandleException(exception_str)


ModlistEntry = namedtuple("ModlistEntry", ["id", "name", "author", "desc", "image_url", "child_list"])

@cache
def github_downloadable_mods():
Expand All @@ -66,34 +68,41 @@ def github_downloadable_mods():
for branch in branches:
name = branch["name"]
if name.startswith("mod-"):
data.append([
data.append(ModlistEntry(
ZIP_LOCATION.format(mod_name=name),
name.replace("mod-", "", 1).encode("utf-8"),
"DummyAuthor",
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?",
"http://s-media-cache-ak0.pinimg.com/originals/42/41/90/424190c7f88c514a1c26a79572d61191.png"
])
"http://s-media-cache-ak0.pinimg.com/originals/42/41/90/424190c7f88c514a1c26a79572d61191.png",
[]
))
return sorted(data, key=lambda mod: mod[1].lower())



def load_steam_modlist():
"""Loads and verifies the steam modlist data."""
# A different format,
# (id, mod_name, author, desc, image_url)
# (id, name, author, desc, image_url, child_list)

# This uses GetAllItems(), Which is affected by the QueryApi crash.
# therefore, steamhandler_extensions are preferred
mods = []
for mod in sorted(steamhandler_extensions.get_instance().GetAllItems(), key=lambda mod: mod[1]):
if mod[0] == MODTOOLS_ID:
continue # The modtools themselves need not be here (as they're already present and can't be removed using themselves), nor should the signing system complain about them...

n_children, child_list = mod[8:10]
# as m_pvecChildrenId may still be a C type, we would rather just make it a list
child_list = [child_list[i] for i in range(n_children)]

file_id = mod[0]
create_time, modify_time, signature = mod[5:8]
is_valid, verified = has_valid_signature(file_id, create_time, modify_time, signature)
if is_valid:
mods.append(list(mod[:5]))
mods[-1][3] += "\n\nVerified by {}".format(verified.username.replace("<postmaster@example.com>", ""))
next_mod = list(mod[:5]) + [child_list]
next_mod[3] += "\n\nVerified by {}".format(verified.username.replace("<postmaster@example.com>", ""))
mods.append(ModlistEntry(*next_mod))
else:
print "NOT VALID SIG", mod[1] # Note: printing only the mod name, instead of the whole thing SIGNIFICANTLY speeds up this call
return mods
Expand Down
17 changes: 15 additions & 2 deletions modloader/steamhandler_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ def fill_cache_query_cb(array, arr_len):
field_names = [name for name, _ in WorkshopData._fields_]
to_write = [{name: getattr(array[i], name) for name in field_names} for i in range(arr_len)]

# m_pvecChildrenId is a type that doesn't work for json, so we fix it up to be one

for item in to_write:
item["m_pvecChildrenId"] = [item["m_pvecChildrenId"][i] for i in range(item["m_unNumChildren"])]

# Write cache file
with open(cache_file_name, "w") as cache_file:
json.dump(to_write, cache_file, encoding="utf-8") # While not strictly necessary, I'd rather be explicit with the encoding.
Expand Down Expand Up @@ -260,8 +265,11 @@ def cb(array, arr_len):
cb.page_complete.set()
return

# child_nums = {}

for x in range(arr_len):
item = array[x]
# child_nums[item.m_nPublishedFileId] = item.m_pvecChildrenId
if get_all:
results.append(copy.deepcopy((item.m_nPublishedFileId, item.m_eResult, item.m_eFileType,
item.m_nCreatorAppID, item.m_nConsumerAppID, item.m_rgchTitle,
Expand All @@ -270,14 +278,19 @@ def cb(array, arr_len):
item.m_bBanned, item.m_bAcceptedForUse, item.m_bTagsTruncated,
item.m_rgchTags, item.m_hFile, item.m_hPreviewFile, item.m_pchFileName,
item.m_nFileSize, item.m_nPreviewFileSize, item.m_rgchURL, item.m_unVotesUp,
item.m_unVotesDown, item.m_flScore, item.m_unNumChildren,
item.m_unVotesDown, item.m_flScore, item.m_unNumChildren, item.m_pvecChildrenId,
item.m_pchPreviewLink, item.m_metadata)))
else:
results.append(copy.deepcopy((item.m_nPublishedFileId, item.m_rgchTitle, item.m_ulSteamIDOwner,
item.m_rgchDescription, item.m_pchPreviewLink, item.m_rtimeCreated,
item.m_rtimeUpdated, item.m_metadata))
item.m_rtimeUpdated, item.m_metadata,
item.m_unNumChildren, item.m_pvecChildrenId))
)

# with open(r"P:\AWSW_Messing_About\childinfo.txt", "a") as f:
# for k, v in child_nums.iteritems():
# f.write("{}: {}\n".format(k, v))

cb.should_run_next = (arr_len == 50)
cb.page_complete.set()

Expand Down
Loading