Jump to content
Rpg²S Forum

*Missing File Debugger


ProGM
 Share

Recommended Posts

Missing File Debugger*


*versione beta, non testato.

Descrizione
Avete un progetto vecchio, buggato e a cui mancano chili di grafica? Ogni 2 secondi il gioco si chiude perché non trova le grafiche di alcuni chara e magari perdete ogni volta il salvataggio? Questo script fa per voi (sa molto di pubblicitario XDD). Ogni volta che manca una grafica segnalerà l'errore, ma il gioco non si chiuderà! Al posto della grafica mancante verrà messa una bitmap trasparente, permettendo però di continuare a giocare.

Autore
ProGM*, ma creditate Rhaxen Team, visto che è stato creato per esso.

*è stato sfruttato un modulo di gestione del registro di sistema presente nel pacchetto Ruby.

Allegati
N/A

Istruzioni per l'uso
Inserite questo codice sopra Main.

CODICE

 

class Bitmap
	if !$a
		alias old_initialize initialize
	end
	def initialize(width, height = nil)
		$a = true
		if width.is_a?(String)
			Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Enterbrain\RGSS\RTP') do |reg|
				@value = reg['Standard']
			end
			for i in [".png", ".jpg", ".jpeg", ".xyz"]
				@a = true if FileTest.exist?(width+i) or FileTest.exist?(@value+width+i)
			end
			if @a
				old_initialize(width)
			else
				print("Impossibile trovare il file #{width}.")
				old_initialize(32, 32)
			end
		else
			old_initialize(width, height)
		end
		@a = nil
	end
end
module Win32
	class Registry
		module Constants
			HKEY_LOCAL_MACHINE = 0x80000002
			
			REG_NONE = 0
			REG_SZ = 1
			REG_EXPAND_SZ = 2
			REG_BINARY = 3
			REG_DWORD = 4
			REG_DWORD_LITTLE_ENDIAN = 4
			REG_DWORD_BIG_ENDIAN = 5
			REG_LINK = 6
			REG_MULTI_SZ = 7
			REG_RESOURCE_LIST = 8
			REG_FULL_RESOURCE_DESCRIPTOR = 9
			REG_RESOURCE_REQUIREMENTS_LIST = 10
			REG_QWORD = 11
			REG_QWORD_LITTLE_ENDIAN = 11
			
			STANDARD_RIGHTS_READ = 0x00020000
			STANDARD_RIGHTS_WRITE = 0x00020000
			KEY_QUERY_VALUE = 0x0001
			KEY_SET_VALUE = 0x0002
			KEY_CREATE_SUB_KEY = 0x0004
			KEY_ENUMERATE_SUB_KEYS = 0x0008
			KEY_NOTIFY = 0x0010
			KEY_CREATE_LINK = 0x0020
			KEY_READ = STANDARD_RIGHTS_READ |
			KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY
			KEY_WRITE = STANDARD_RIGHTS_WRITE |
			KEY_SET_VALUE | KEY_CREATE_SUB_KEY
			KEY_EXECUTE = KEY_READ
			KEY_ALL_ACCESS = KEY_READ | KEY_WRITE | KEY_CREATE_LINK
			
			REG_OPTION_RESERVED = 0x0000
			REG_OPTION_NON_VOLATILE = 0x0000
			REG_OPTION_VOLATILE = 0x0001
			REG_OPTION_CREATE_LINK = 0x0002
			REG_OPTION_BACKUP_RESTORE = 0x0004
			REG_OPTION_OPEN_LINK = 0x0008
			REG_LEGAL_OPTION = REG_OPTION_RESERVED |
			REG_OPTION_NON_VOLATILE | REG_OPTION_CREATE_LINK |
			REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK
			
			REG_CREATED_NEW_KEY = 1
			REG_OPENED_EXISTING_KEY = 2
			
			REG_WHOLE_HIVE_VOLATILE = 0x0001
			REG_REFRESH_HIVE = 0x0002
			REG_NO_LAZY_FLUSH = 0x0004
			REG_FORCE_RESTORE = 0x0008
			
			MAX_KEY_LENGTH = 514
			MAX_VALUE_LENGTH = 32768
		end
		include Constants
		include Enumerable
		class Error < ::StandardError
			FormatMessageA = Win32API.new('kernel32.dll', 'FormatMessageA', 'LPLLPLP', 'L')
			def initialize(code)
				@code = code
				msg = "\0" * 1024
				len = FormatMessageA.call(0x1200, 0, code, 0, msg, 1024, 0)
				super msg[0, len].tr("\r", '').chomp
			end
			attr_reader :code
		end
		class PredefinedKey < Registry
			def initialize(hkey, keyname)
				@hkey = hkey
				@parent = nil
				@keyname = keyname
				@disposition = REG_OPENED_EXISTING_KEY
			end
			
			# Predefined keys cannot be closed
			def close
				raise Error.new(5) ## ERROR_ACCESS_DENIED
			end
			
			# Fake class for Registry#open, Registry#create
			def class
				Registry
			end
			Constants.constants.grep(/^HKEY_/) do |c|
				Registry.const_set c, new(Constants.const_get(c), c)
			end
		end
		module API
			[
			%w/RegOpenKeyExA	LPLLP		L/,
			%w/RegQueryValueExA LPLPPP	   L/,
			%w/RegCloseKey	  L			L/,
			].each do |fn|
				const_set fn[0].intern, Win32API.new('advapi32.dll', *fn)
			end
			
			module_function
			
			def check(result)
				raise Error, result, caller(2) if result != 0
			end
			
			def packdw(dw)
				[dw].pack('V')
			end
			
			def unpackdw(dw)
				dw += [0].pack('V')
				dw.unpack('V')[0]
			end
			
			def packqw(qw)
				[ qw & 0xFFFFFFFF, qw >> 32 ].pack('VV')
			end
			
			def unpackqw(qw)
				qw = qw.unpack('VV')
				(qw[1] << 32) | qw[0]
			end
			
			def OpenKey(hkey, name, opt, desired)
				result = packdw(0)
				check RegOpenKeyExA.call(hkey, name, opt, desired, result)
				unpackdw(result)
			end
			def QueryValue(hkey, name)
				type = packdw(0)
				size = packdw(0)
				check RegQueryValueExA.call(hkey, name, 0, type, 0, size)
				data = ' ' * unpackdw(size)
				check RegQueryValueExA.call(hkey, name, 0, type, data, size)
				[ unpackdw(type), data[0, unpackdw(size)] ]
			end
			def CloseKey(hkey)
				check RegCloseKey.call(hkey)
			end
		end
		def self.expand_environ(str)
			str.gsub(/%([^%]+)%/) { ENV[$1] || $& }
		end
		
		@@type2name = { }
		%w[
		REG_NONE REG_SZ REG_EXPAND_SZ REG_BINARY REG_DWORD
		REG_DWORD_BIG_ENDIAN REG_LINK REG_MULTI_SZ
		REG_RESOURCE_LIST REG_FULL_RESOURCE_DESCRIPTOR
		REG_RESOURCE_REQUIREMENTS_LIST REG_QWORD
		].each do |type|
			@@type2name[Constants.const_get(type)] = type
		end
		
		def self.type2name(type)
			@@type2name[type] || type.to_s
		end
		
		def self.wtime2time(wtime)
			Time.at((wtime - 116444736000000000) / 10000000)
		end
		
		def self.time2wtime(time)
			time.to_i * 10000000 + 116444736000000000
		end
		private_class_method :new
		
		def self.open(hkey, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
			subkey = subkey.chomp('\\')
			newkey = API.OpenKey(hkey.hkey, subkey, opt, desired)
			obj = new(newkey, hkey, subkey, REG_OPENED_EXISTING_KEY)
			if block_given?
				begin
					yield obj
					ensure
					obj.close
				end
			else
				obj
			end
		end
		
		def self.create(hkey, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
			newkey, disp = API.CreateKey(hkey.hkey, subkey, opt, desired)
			obj = new(newkey, hkey, subkey, disp)
			if block_given?
				begin
					yield obj
					ensure
					obj.close
				end
			else
				obj
			end
		end
		@@final = proc { |hkey| proc { API.CloseKey(hkey[0]) if hkey[0] } }
		def initialize(hkey, parent, keyname, disposition)
			@hkey = hkey
			@parent = parent
			@keyname = keyname
			@disposition = disposition
			@hkeyfinal = [ hkey ]
			ObjectSpace.define_finalizer self, @@final.call(@hkeyfinal)
		end
		attr_reader :hkey, :parent, :keyname, :disposition
		
		#
		# attributes
		#
		def created?
			@disposition == REG_CREATED_NEW_KEY
		end
		
		def open?
			!@hkey.nil?
		end
		
		def name
			parent = self
			name = @keyname
			while parent = parent.parent
				name = parent.keyname + '\\' + name
			end
			name
		end
		
		def inspect
			"\#"
		end
		
		#
		# marshalling
		#
		def _dump(depth)
			raise TypeError, "can't dump Win32::Registry"
		end
		
		#
		# open/close
		#
		def open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED, &blk)
			self.class.open(self, subkey, desired, opt, &blk)
		end
		def close
			API.CloseKey(@hkey)
			@hkey = @parent = @keyname = nil
			@hkeyfinal[0] = nil
		end
		#
		# reader
		#
		def read(name, *rtype)
			type, data = API.QueryValue(@hkey, name)
			unless rtype.empty? or rtype.include?(type)
				raise TypeError, "Type mismatch (expect #{rtype.inspect} but #{type} present)"
			end
			case type
			when REG_SZ, REG_EXPAND_SZ
				[ type, data.chop ]
			when REG_MULTI_SZ
				[ type, data.split(//) ]
			when REG_BINARY
				[ type, data ]
			when REG_DWORD
				[ type, API.unpackdw(data) ]
			when REG_DWORD_BIG_ENDIAN
				[ type, data.unpack('N')[0] ]
			when REG_QWORD
				[ type, API.unpackqw(data) ]
			else
				raise TypeError, "Type #{type} is not supported."
			end
		end
		
		def [](name, *rtype)
			type, data = read(name, *rtype)
			case type
			when REG_SZ, REG_DWORD, REG_QWORD, REG_MULTI_SZ
				data
			when REG_EXPAND_SZ
				Registry.expand_environ(data)
			else
				raise TypeError, "Type #{type} is not supported."
			end
		end
		
		def read_s(name)
			read(name, REG_SZ)[1]
		end
		
		def read_s_expand(name)
			type, data = read(name, REG_SZ, REG_EXPAND_SZ)
			if type == REG_EXPAND_SZ
				Registry.expand_environ(data)
			else
				data
			end
		end
		
		def read_i(name)
			read(name, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD)[1]
		end
		
		def read_bin(name)
			read(name, REG_BINARY)[1]
		end
		
		def []=(name, rtype, value = nil)
			if value
				write name, rtype, value
			else
				case value = rtype
				when Integer
					write name, REG_DWORD, value
				when String
					write name, REG_SZ, value
				when Array
					write name, REG_MULTI_SZ, value
				else
					raise TypeError, "Unexpected type #{value.class}"
				end
			end
			value
		end
	end
end

 

 

 

Progetti:

 http://i.imgur.com/jmLkIqi.png

http://i54.tinypic.com/2rh4ojq.png

https://github.com/ProGM

 

Crea anche tu il tuo gioco per Game Boy!
http://rpg2s.net/gif/SCContest3Oct.gifhttp://www.rpg2s.net/img/fablecontest1st.pnghttp://i43.tinypic.com/1zokd2s.png


http://i.imgur.com/BEu6G.gif

http://i.imgur.com/H1ARhq7.gif

http://i.imgur.com/Af6ijZN.gif

AOT: Associazione Odiamo la Telecom:

http://i.imgur.com/aYJs89E.png

"4 gattini... 4 stelline... E le 4 paperelle non ci stavano :3"

Flame


http://i30.tinypic.com/i27ypj.png

Link to comment
Share on other sites

E' un signor script, complimenti Progm :D

Magari se riesci puoi metterlo anche con i file audio ^^

"Dopo gli ultimi Final Fantasy, ho capito solamente una cosa: che il gioco è bello quando Nomura poco."

Making is not dead. You are dead.
RELEASE: La Bussola d'Oro | Download | Video di anteprima - La Partenza di Hanna

http://i.imgur.com/cFgc2lW.png

Prova Standrama!

Link to comment
Share on other sites

Ottimo :wink:

Progetto in corso:

"Hero Walking: Toward Another Life"

Video Old Intro su Youtube

Visite: 11.896!

http://img212.imageshack.us/img212/1060/logheryb0.jpg

 

 

*Posizioni raggiunte nei contest*

 

 

http://www.rpg2s.net/awards/bestuser1.jpghttp://www.rpg2s.net/awards/beststaff1.jpg

http://www.rpg2s.net/awards/bestmaker3.jpghttp://www.rpg2s.net/awards/bestcritical1.jpghttp://www.rpg2s.net/awards/mostcharismatic2.jpg

http://www.rpg2s.net/awards/mosthelpful1.jpghttp://www.rpg2s.net/awards/mostpolite1.jpghttp://www.rpg2s.net/awards/mostpresent1.jpg

 

http://img204.imageshack.us/img204/8039/sccontest3octpl3.gif http://img103.imageshack.us/img103/1496/sccontest2octou1.gif http://img118.imageshack.us/img118/181/sccontest1octdt9.gif http://img230.imageshack.us/img230/1273/sccontest1batio5.gif http://img103.imageshack.us/img103/1496/sccontest2octou1.gif http://img103.imageshack.us/img103/1496/sccontest2octou1.gif http://img103.imageshack.us/img103/1496/sccontest2octou1.gif http://img143.imageshack.us/img143/3755/destroyae4.png

http://img141.imageshack.us/img141/3081/comics3od3.gif http://img118.imageshack.us/img118/181/sccontest1octdt9.gif

 

 

SE VUOI AVERE RENS PER RISORSE, TUTORIAL, DEMO, ECC... LEGGI QUI

Link to comment
Share on other sites

Secondo me se aggiungi la stampa su un file di testo con l'elenco dei file mancanti diventa perfetto ;)

 

PS: Magari come suggerisce Tio si potrebbe mettere anche per l'audio, non credo sia molto difficile.

Link to comment
Share on other sites

Si è vero, anche se già così com'è è utilissimo!

"Quarantadue!" urlò Loonquawl. "Questo è tutto ciò che sai dire dopo un lavoro di sette milioni e mezzo di anni?"

"Ho controllato molto approfonditamente," disse il computer, "e questa è sicuramente la risposta. Ad essere sinceri, penso che il problema sia che voi non abbiate mai saputo veramente qual è la domanda."

 

 

 

Gioco disponibile: Prophecy of Last Era - OPEN SOURCE

 

http://www.mediafire.com/?u6aut42ks12ixgf

 

Puoi utilizzare qualsiasi evento, mappa, chara, grafica, e programmazione contenuta nel gioco-demo.

Nessun diritto di copia.

Hope you enjoy.

http://www.rpg2s.net/awards/bestmusician3.jpg

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...