Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[0e48a2]: plugins / core.py Maximize Restore History

Download this file

core.py    178 lines (151 with data), 3.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# -*-python-*-
import string
global formats
formats = {}
global strrefs
strrefs = None
global keys
keys = None
global options
options = {}
# Loaded IDS files
global ids
ids = {}
game_dir = None
chitin_file = 'CHITIN.KEY'
dialog_file = 'dialog.tlk'
xor_key = "\x88\xa8\x8f\xba\x8a\xd3\xb9\xf5\xed\xb1\xcf\xea\xaa\xe4\xb5\xfb\xeb\x82\xf9\x90\xca\xc9\xb5\xe7\xdc\x8e\xb7\xac\xee\xf7\xe0\xca\x8e\xea\xca\x80\xce\xc5\xad\xb7\xc4\xd0\x84\x93\xd5\xf0\xeb\xc8\xb4\x9d\xcc\xaf\xa5\x95\xba\x99\x87\xd2\x9d\xe3\x91\xba\x90\xca"
global slash_trans
slash_trans = string.maketrans ('\\', '/')
t_cp1250 = 'áčďéěíňóřšúůýžÁČĎÉĚÍŇÓ؊ÚŮݎ'
t_iso8859_2 = 'áčďéěíňóřšťúůýžÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ'
global lang_trans
lang_trans = string.maketrans (t_cp1250, t_iso8859_2)
def translate_to_iso (s):
return string.translate (s, lang_trans)
def cond (c, a, b):
if c: return a
else: return b
def translate_to_ord (s):
return map (lambda c: (cond (ord (c) < 128, c, "\\x%02X" %(ord (c))), s))
restype_list = [
[0x0001, 'BMP', ''],
[0x0002, 'MVE', ''],
[0x0004, 'WAV', ''],
[0x0004, 'WAVC', ''],
[0x0005, 'WFX', ''],
[0x0006, 'PLT', ''],
[0x03e8, 'BAM', ''],
[0x03e8, 'BAMC', ''],
[0x03e9, 'WED', ''],
[0x03ea, 'CHUI', ''],
[0x03eb, 'TIS', ''],
[0x03ec, 'MOS', ''],
[0x03ec, 'MOSC', ''],
[0x03ed, 'ITM', ''],
[0x03ee, 'SPL', ''],
[0x03ef, 'BCS', ''],
[0x03f0, 'IDS', ''],
[0x03f1, 'CRE', ''],
[0x03f2, 'ARE', ''],
[0x03f3, 'DLG', ''],
[0x03f4, '2DA', ''],
[0x03f5, 'GAME', ''],
[0x03f6, 'STOR', ''],
[0x03f7, 'WMAP', ''],
[0x03f8, 'CHR', ''],
[0x03f8, 'EFF', ''],
[0x03f9, 'BS', ''],
[0x03fa, 'CHR', ''],
[0x03fb, 'VVC', ''],
[0x03fc, 'VEF', ''],
[0x03fd, 'PRO', ''],
[0x03fe, 'BIO', ''],
[0x044c, 'BAH', ''],
[0x0802, 'INI', ''],
[0x0803, 'SRC', ''],
]
restype_hash = {
0x0001 : 'BMP',
0x0002 : 'MVE',
0x0004 : 'WAV', # also WAVC
0x0005 : 'WFX',
0x0006 : 'PLT',
0x03e8 : 'BAM', # also BAMC
0x03e9 : 'WED',
0x03ea : 'CHUI',
0x03eb : 'TIS',
0x03ec : 'MOS', # also MOSC
0x03ed : 'ITM',
0x03ee : 'SPL',
0x03ef : 'BCS',
0x03f0 : 'IDS',
0x03f1 : 'CRE',
0x03f2 : 'ARE',
0x03f3 : 'DLG',
0x03f4 : '2DA',
0x03f5 : 'GAME',
0x03f6 : 'STOR',
0x03f7 : 'WMAP',
0x03f8 : 'CHR', # also EFF
0x03f9 : 'BS',
0x03fa : 'CHR',
0x03fb : 'VVC',
0x03fc : 'VEF',
0x03fd : 'PRO',
0x03fe : 'BIO',
0x044c : 'BAH',
0x0802 : 'INI',
0x0803 : 'SRC',
}
restype_rev_hash = {
'2DA' : 0x03f4,
'ARE' : 0x03f2,
'BAH' : 0x044c,
'BAM' : 0x03e8,
'BAMC' : 0x03e8,
'BCS' : 0x03ef,
'BIO' : 0x03fe,
'BMP' : 0x0001,
'BS' : 0x03f9,
'CHR' : 0x03fa,
#'CHR' : 0x03f8,
'CHUI' : 0x03ea,
'CRE' : 0x03f1,
'DLG' : 0x03f3,
'EFF' : 0x03f8,
'GAME' : 0x03f5,
'IDS' : 0x03f0,
'INI' : 0x0802,
'ITM' : 0x03ed,
'MOS' : 0x03ec,
'MOSC' : 0x03ec,
'MVE' : 0x0002,
'PLT' : 0x0006,
'PRO' : 0x03fd,
'SPL' : 0x03ee,
'SRC' : 0x0803,
'STOR' : 0x03f6,
'TIS' : 0x03eb,
'VEF' : 0x03fc,
'VVC' : 0x03fb,
'WAV' : 0x0004,
'WAVC' : 0x0004,
'WED' : 0x03e9,
'WFX' : 0x0005,
'WMAP' : 0x03f7,
}
def register_format (signature, version, klass):
#core.formats[(signature, version)] = klass
formats[signature] = klass
def get_format (signature, version = None):
try:
return formats[signature]
except:
return None
def get_format_by_type (type):
try:
signature = restype_hash[type]
return get_format (signature)
except:
return None