[Wine] C++ runtime error

DraycosGoldaryn wineforum-user at winehq.org
Sat Aug 7 12:34:53 CDT 2010


Greetings,

I'm having a slight error with a certain program in wine. I'm using RPG Maker XP to make an rpg game. It utilizes a modified version of ruby called RGSS. I am using a script that opens a debug output console, it works fine in M$ Windows,  but I get the following error in wine:


> Microsoft Visual C++ Runtime Library
> Runtime Error!
> 
> Program: E:\RPGXP\SDK\Game.exe
> 
> 
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.


Here is the script in question:


Code:
#===============================================================================
# ** Debug
#-------------------------------------------------------------------------------
#  Provides a console window to log debugging messages and prints to a log file
#===============================================================================

module Debug
  @active = false
  begin
    @file = File.open('debug.log', File::CREAT|File::APPEND|File::WRONLY)
  rescue IOError
    print "Could not open debug.log for writing"
  end
  #-----------------------------------------------------------------------------
  # * Open a console window for debug output
  #-----------------------------------------------------------------------------
  def self.start
    @active = true

    if self.active
      # Open console window and select it for :puts
      Win32API.new("kernel32", "AllocConsole", "V", "L").call
      $stdout.reopen("CONOUT$")
      # Bring the game window back to the front
      Win32API.new("user32", "SetForegroundWindow", "L", "L").call(hwnd)      
      f = File.open("Game.ini") 
      lines = f.readlines() 
      s = lines[3] 
      len = s.size 
      title = (s[6,len - 7]) 
  
      Win32API.new("kernel32","SetConsoleTitleA","p","s").call("#{title} -- " +
                                                              "Debug Console") 
    end

    self.header
  end
  #-----------------------------------------------------------------------------
  # * Stop debugging
  #-----------------------------------------------------------------------------
  def self.stop
    Win32API.new("kernel32", "FreeConsole", "", "L").call if self.active
    @active = false
  end
  #-----------------------------------------------------------------------------
  # * Write log headers
  #-----------------------------------------------------------------------------
  def self.header
    return if @written
    @written = true
    # Write log headers
    self.log("========================================================")
    self.log(Time.now)
    self.log("--------------------------------------------------------")
  end
  #-----------------------------------------------------------------------------
  # * Stop debugging
  #-----------------------------------------------------------------------------
  def self.active
    return (@active and ($TEST or $DEBUG))
  end
  #-----------------------------------------------------------------------------
  # * Write to console
  #-----------------------------------------------------------------------------
  def self.log(string)
    self.header
    puts string if self.active
    @file.print string.to_s + "\n" if @file != nil
  end
  #-----------------------------------------------------------------------------
  # * Write to console; not done every frame
  #-----------------------------------------------------------------------------
  def self.log_by_frame(string, sec = 5)
    self.log(string) if Graphics.frame_count % (Graphics.frame_rate * sec) == 0
  end
  #-----------------------------------------------------------------------------
  # * Find the game window and return it
  #-----------------------------------------------------------------------------
  def self.hwnd

    if $HWND == nil
      find = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
      $HWND = find.call('RGSS Player', Settings["Title"])
    end
    # Finds Window
    return $HWND

  end
  self.start
end



After some extensive testing, I have determined the following line of code to be the cause of the error:


Code:
      $stdout.reopen("CONOUT$")



This line is the one that directs ruby to print to the console window. I don't get the error if I comment out the line, but nothing gets printed to the console either. Can anyone tell me how to fix this?

Thank you,

Draycos Goldaryn







More information about the wine-users mailing list