Commit 940f2b07 authored by zh99998's avatar zh99998

取消#encoding: UTF-8声明,改为-KU参数,因为在logger里不声明-KU会比较纠结

parent 1cd3c81c
== mycard
这是一个游戏王对战器,与NBX和iDuel、ygocore协议兼容
目前开发进度约60%,iDuel实现了观战、播放Replay和几个简单的战斗指令,ygocore的大厅
快捷键:
F12 返回标题画面
iduel观战时 F10退出房间
常见问题:
Q: 运行主程序没有任何反应
A: 不支持中文目录,请把程序放到没有中文的目录下,例如d:\mycard,而不要放到d:\游戏\mycard,也不要放到桌面。
Q: 切换输入法时卡死
A: 这个故障只在WinXP上出现,暂时没有解决方案,可以临时在其他地方写好文字复制进来;如果一点决斗开始立即卡死,那么可能是默认有输入法,把默认输入法调成英文。
Q: 加入或建立房间时提示连接已断开
A: 可能是ygocore版本不正确,截止到3月13日服务器支持的ygocore版本是0x1023,一般ygocore发布新版本后会在1到3天升级,请留意公告。如果大厅内没有房间,并且无法建立房间,那么可能是服务器维护。
Q: 弹出【程序可能出现了一个bug,请到论坛反馈】
== mycard
这是一个游戏王对战器,与NBX和iDuel、ygocore协议兼容
目前开发进度约60%,iDuel实现了观战、播放Replay和几个简单的战斗指令,ygocore的大厅
快捷键:
F12 返回标题画面
iduel观战时 F10退出房间
常见问题:
Q: 运行主程序没有任何反应
A: 不支持中文目录,请把程序放到没有中文的目录下,例如d:\mycard,而不要放到d:\游戏\mycard,也不要放到桌面。
Q: 切换输入法时卡死
A: 这个故障只在WinXP上出现,暂时没有解决方案,可以临时在其他地方写好文字复制进来;如果一点决斗开始立即卡死,那么可能是默认有输入法,把默认输入法调成英文。
Q: 加入或建立房间时提示连接已断开
A: 可能是ygocore版本不正确,截止到3月13日服务器支持的ygocore版本是0x1023,一般ygocore发布新版本后会在1到3天升级,请留意公告。如果大厅内没有房间,并且无法建立房间,那么可能是服务器维护。
Q: 弹出【程序可能出现了一个bug,请到论坛反馈】
A: 联系作者 E-mail/QQ/GT: zh99998@gmail.com,或者到iduel社区的mycard发布帖留言。
\ No newline at end of file
......@@ -47,9 +47,9 @@ Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
if Windows
p.need_zip = true
p.zip_command = '../7z.exe a -tzip'
p.zip_command = '../7z.exe a'
def p.zip_file
"#{package_name}-win32.zip"
"#{package_name}-win32.7z"
end
else
p.need_tar = true
......
#encoding: UTF-8
class ChatMessage
attr_accessor :user, :message, :channel, :time
def initialize(user,message,channel=:lobby,time=Time.now)
......
#encoding: UTF-8
#游戏适配器的抽象类
require_relative 'game_event'
require_relative 'action'
......
#encoding: UTF-8
class Game_Card
attr_accessor :card, :position, :counters, :note
attr_writer :atk, :def
......
#encoding: UTF-8
#游戏事件的抽象类
class Game_Event
@queue = []
......@@ -140,7 +138,8 @@ class Game_Event
@title = title
@message = message
@fatal = fatal
$log.error(@fatal ? "致命错误" : "一般错误"){"#{@title}: #{@message} #{caller}"}
p @title, @title.encoding, @message, @message.encoding, caller.to_s.encoding
$log.error(@fatal ? "致命错误" : "一般错误"){"#{@title}: #{@message.encode("UTF-8")} #{caller}"}
end
end
class Unknown < Error
......
#encoding: UTF-8
#==============================================================================
# ■ Field
#------------------------------------------------------------------------------
......
#encoding: UTF-8
class Action
CardFilter = /(<?\[?Token[ \\\d]*\]?>?|<?(?:\[.*?\])?\[(?:.*?)\][ \d?]*>?|一张怪兽卡|一张魔\/陷卡|一张卡|\?\?)/.to_s
PosFilter = /((?:手卡|手牌|场上|魔陷区|怪兽区|墓地|墓地\|,,,,,\|\*\:\d+张\:\*|额外牌堆|除外区|卡组|卡组顶端|\(\d+\)){1,2})/.to_s
......
#encoding: UTF-8
class Game_Event
def self.parse(info)
info =~ /^\$([A-Z])\|(.*)$/m
......
......@@ -113,7 +113,7 @@ class Iduel < Game
save_config
end
rescue Exception => exception
$log.error('读取好友信息') {[exception.inspect, *exception.backtrace].join("\n").encode("UTF-8")}
$log.error('读取好友信息') {[exception.inspect, *exception.backtrace].collect{|str|str.encode("UTF-8")}.join("\n")}
end
end
end
......@@ -124,19 +124,20 @@ class Iduel < Game
@conn = TCPSocket.new(Server, Port) #TODO: 阻塞优化,注意login。下面注释掉的两句实现connect无阻塞,但是login依然会阻塞所以只优化这里没有意义
#@conn = Socket.new(:INET, :STREAM)
@conn.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace
Thread.abort_on_exception=true
@recv = Thread.new do
begin
#@conn.connect Socket.pack_sockaddr_in(Port, Server)
recv @conn.gets(RS) while @conn
rescue => exception
$log.error('iduel-connect-1') {[exception.inspect, *exception.backtrace].join("\n")}
$log.error('iduel-connect-1') {[exception.inspect, *exception.backtrace].collect{|str|str.encode("UTF-8")}.join("\n")}
Game_Event.push Game_Event::Error.new(exception.class.to_s, exception.message)
ensure
self.exit
end
end
rescue => exception
$log.error('iduel-connect-2') {[exception.inspect, *exception.backtrace].join("\n")}
$log.error('iduel-connect-2') {[exception.inspect, *exception.backtrace].collect{|str|str.encode("UTF-8")}.join("\n")}
Game_Event.push Game_Event::Error.new("网络错误", "连接服务器失败")
end
end
......@@ -170,7 +171,7 @@ class Iduel < Game
save_config
end
rescue Exception => exception
$log.error('公告') {[exception.inspect, *exception.backtrace].join("\n")}
$log.error('公告') {[exception.inspect, *exception.backtrace].collect{|str|str.encode("UTF-8")}.join("\n")}
end
end
end
......
#encoding: UTF-8
class Replay
User_Filter = /(.+?)(?:\((\d+)\))?(?:\(\d+:\d+:\d+\))?(?:: |:) */
Delimiter = /^#{User_Filter}\n ?/
......
#encoding: UTF-8
class Window_Login
def clicked
return if @last_clicked and Time.now - @last_clicked < 3 #防止重复点击
......
#!/usr/bin/env ruby
#encoding: UTF-8
begin
#定义全局方法
......@@ -46,13 +45,13 @@ begin
$screen = Screen.open($config['screen']['width'], $config['screen']['height'], 0, HWSURFACE | ($config['screen']['fullscreen'] ? FULLSCREEN : 0))
Mixer.open(Mixer::DEFAULT_FREQUENCY,Mixer::DEFAULT_FORMAT,Mixer::DEFAULT_CHANNELS,512)
TTF.init
#设置标准输出编码(windows)
STDOUT.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace if RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
Thread.abort_on_exception = true
#初始化日志
require 'logger'
if log == "STDOUT" #调试用
log = STDOUT
STDOUT.set_encoding "GBK", "UTF-8", :invalid => :replace, :undef => :replace if RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
end
$log = Logger.new(log)
$log.level = Logger.const_get log_level
......
#encoding: UTF-8
require_relative 'cacheable'
class Room
Color = [[0,0,0], [255,0,0], [0,128,0], [0,0,255], [255, 165, 0]]
......
#encoding: UTF-8
require_relative 'widget_msgbox'
class Scene_Error < Scene
def start
......
#encoding: UTF-8
require_relative 'scene_watch'
class Scene_Replay < Scene_Watch
def initialize(replay)
......
#encoding: UTF-8
class Widget_InputBox < Window
attr_reader :value, :proc
attr_accessor :type
......
#encoding: UTF-8
class Widget_Msgbox < Window
Title_Color = [0xFF, 0xFF, 0xFF]
Message_Color = [0x04, 0x47, 0x7c]
......
#encoding: UTF-8
require_relative 'window'
class Window_BGM < Window
WLH=20
......
#encoding: UTF-8
class Window_CardInfo < Window
WLH = 20
def initialize(x,y)
......
#encoding: UTF-8
class Window_Config < Window
def initialize(x,y)
super(x,y,$screen.w, $screen.h)
......
#encoding: UTF-8
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
......
#encoding: UTF-8
class Window_GameSelect < Window_List
WLH = 56
def initialize(x,y)
......
#encoding: UTF-8
class Window_Host < Window
attr_reader :index
def initialize(x,y)
......
#encoding: UTF-8
#==============================================================================
# ■ Window_Roomitems
#------------------------------------------------------------------------------
......
#encoding: UTF-8
require_relative 'window_host'
class Window_LobbyButtons < Window_List
def initialize(x,y)
......
#encoding: UTF-8
require_relative 'widget_inputbox'
require_relative 'widget_msgbox'
require_relative 'widget_checkbox'
......
#encoding: UTF-8
require_relative 'window_list'
class Window_Scrollable < Window_List
attr_reader :scroll
......
#encoding: UTF-8
require_relative 'window_list'
class Window_Title < Window_List
Button_Count = 5
......
#encoding: UTF-8
class Window_User < Window_List
WLH = 20
def initialize(x, y, user)
......
#encoding: UTF-8
class Game_Event
User_Filter = /\[(\d+),<font color="(?:blue|gray)">(.+?)(\(未认证\)|)<\/font>\]/
Room_Filter = /\[(\d+),(.+?),(wait|start)#{User_Filter}+?\]/
......
#encoding: UTF-8
class Room
attr_accessor :pvp
attr_accessor :match
......
#encoding: UTF-8
class Scene_Lobby
WM_LBUTTONDOWN = 0x201
WM_LBUTTONUP = 0x202
......
#encoding: UTF-8
class User
def initialize(id, name = "", certified = true)
@id = id
......
#encoding: UTF-8
class Window_Login
def clicked
return if @last_clicked and Time.now - @last_clicked < 3 #防止重复点击
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment