~ubuntu-branches/ubuntu/utopic/rlvm/utopic-proposed

« back to all changes in this revision

Viewing changes to src/libReallive/scenario.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ying-Chun Liu (PaulLiu), Ying-Chun Liu (PaulLiu), Elliot Glaysher
  • Date: 2011-05-19 00:28:44 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110519002844-qszwmj7oiixww0eg
Tags: 0.12-1
[ Ying-Chun Liu (PaulLiu) <paulliu@debian.org> ]
* New upstream release

[ Elliot Glaysher <glaysher@umich.edu> ]
* New GTK+ interface with desktop integration and UI refinements
* Partial Japanese localizations
* Fix graphics corruption in in-game dialogs when a dialog is brought
  up, and then fullscreen mode activated
* Smooth the output of text in rlBabel using games
* Don't play voice samples while fast forwarding

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include <algorithm>
39
39
#include <sstream>
40
40
 
 
41
#include "Utilities/Exception.hpp"
 
42
#include "Utilities/StringUtilities.hpp"
 
43
#include "Utilities/gettext.h"
 
44
 
41
45
using namespace std;
42
46
 
43
47
namespace libReallive {
105
109
}
106
110
 
107
111
Script::Script(const Header& hdr, const char* data, const size_t length,
108
 
               const Compression::XorKey* second_level_xor_key)
 
112
               const std::string& regname,
 
113
               bool use_xor_2, const Compression::XorKey* second_level_xor_key)
109
114
  : uptodate(true), strip(false) {
110
115
  // Kidoku/entrypoint table
111
116
  const int kidoku_offs = read_i32(data + 0x08);
117
122
  // Decompress data
118
123
  const size_t dlen = read_i32(data + 0x24);
119
124
 
 
125
  const Compression::XorKey* key = NULL;
 
126
  if (use_xor_2) {
 
127
    if (second_level_xor_key) {
 
128
      key = second_level_xor_key;
 
129
    } else {
 
130
      // Probably safe to assume that any game we don't know about has a
 
131
      // Japanese encoding.
 
132
      throw rlvm::UserPresentableError(
 
133
          str(format(_("Can not read game script for %1%")) %
 
134
              cp932toUTF8(regname, 0)),
 
135
          _("Some games require individual reverse engineering. This game can "
 
136
            "not be played until someone has figured out how the game script "
 
137
            "is encoded."));
 
138
    }
 
139
  }
 
140
 
120
141
  /// @todo Removed auto_ptr because of new[] / delete mismatch
121
142
  char* uncompressed = new char[dlen];
122
143
  Compression::decompress(data + read_i32(data + 0x20),
123
144
                          read_i32(data + 0x28),
124
145
                          uncompressed,
125
146
                          dlen,
126
 
                          second_level_xor_key);
 
147
                          key);
127
148
  // Read bytecode
128
149
  const char* stream = uncompressed;
129
150
  const char* end = uncompressed + dlen;